Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Euclidean algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Euclidean_algorithm"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Euclidean_algorithm rootpage-Euclidean_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Euclidean algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about an algorithm for the greatest common divisor. For the mathematics of space, see <a href="Euclidean_geometry" title="Euclidean geometry">Euclidean geometry</a>. For other uses of "Euclidean", see <a href="Euclidean_(disambiguation)" class="mw-redirect mw-disambig" title="Euclidean (disambiguation)">Euclidean (disambiguation)</a>.</div>
<div role="note" class="hatnote navigation-not-searchable">Not to be confused with <a href="Euclidean_division" title="Euclidean division">Euclidean division</a>.</div>
<p class="mw-empty-elt">
</p>

<p>In <a href="Mathematics" title="Mathematics">mathematics</a>, the <b>Euclidean algorithm</b>,<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>note 1<span class="cite-bracket">]</span></a></sup> or <b>Euclid's algorithm</b>, is an efficient method for computing the <a href="Greatest_common_divisor" title="Greatest common divisor">greatest common divisor</a> (GCD) of two <a href="Integers" class="mw-redirect" title="Integers">integers</a>, the largest number that divides them both without a <a href="Remainder" title="Remainder">remainder</a>. It is named after the ancient Greek <a href="Mathematician" title="Mathematician">mathematician</a> <a href="Euclid" title="Euclid">Euclid</a>, who first described it in <a href="Euclid's_Elements" title="Euclid's Elements">his <i>Elements</i></a> (<abbr title="circa">c.</abbr><span style="white-space:nowrap;"> 300 BC</span>).
It is an example of an <i><a href="Algorithm" title="Algorithm">algorithm</a></i>, and is one of the oldest algorithms in common use. It can be used to reduce <a href="Fraction_(mathematics)" class="mw-redirect" title="Fraction (mathematics)">fractions</a> to their <a href="Irreducible_fraction" title="Irreducible fraction">simplest form</a>, and is a part of many other number-theoretic and cryptographic calculations.
</p><p>The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number. For example, <span class="texhtml">21</span> is the GCD of <span class="texhtml">252</span> and <span class="texhtml">105</span> (as <span class="texhtml">252 = 21 × 12</span> and <span class="texhtml">105 = 21 × 5)</span>, and the same number <span class="texhtml">21</span> is also the GCD of <span class="texhtml">105</span> and <span class="texhtml">252 − 105 = 147</span>. Since this replacement reduces the larger of the two numbers, repeating this process gives successively smaller pairs of numbers until the two numbers become equal. When that occurs, that number is the GCD of the original two numbers. By <a href="#Bézout's_identity">reversing the steps</a> or using the <a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">extended Euclidean algorithm</a>, the GCD can be expressed as a <a href="Linear_combination" title="Linear combination">linear combination</a> of the two original numbers, that is the sum of the two numbers, each multiplied by an <a href="Integer" title="Integer">integer</a> (for example, <span class="texhtml">21 = 5 × 105 + (−2) × 252</span>). The fact that the GCD can always be expressed in this way is known as <a href="B%C3%A9zout's_identity" title="Bézout's identity">Bézout's identity</a>.
</p><p>The version of the Euclidean algorithm described above—which follows Euclid's original presentation—may require many subtraction steps to find the GCD when one of the given numbers is much bigger than the other. A more efficient version of the algorithm shortcuts these steps, instead replacing the larger of the two numbers by its remainder when divided by the smaller of the two (with this version, the algorithm stops when reaching a zero remainder). With this improvement, the algorithm never requires more steps than five times the number of digits (base 10) of the smaller integer. This was proven by <a href="Gabriel_Lam%C3%A9" title="Gabriel Lamé">Gabriel Lamé</a> in 1844 (<a href="Lam%C3%A9%E2%80%99s_Theorem" class="mw-redirect" title="Lamé’s Theorem">Lamé's Theorem</a>),<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> and marks the beginning of <a href="Computational_complexity_theory" title="Computational complexity theory">computational complexity theory</a>. Additional methods for improving the algorithm's efficiency were developed in the 20th century.
</p><p>The Euclidean algorithm has many theoretical and practical applications. It is used for reducing <a href="Fraction_(mathematics)" class="mw-redirect" title="Fraction (mathematics)">fractions</a> to their <a href="Irreducible_fraction" title="Irreducible fraction">simplest form</a> and for performing <a href="Division_(mathematics)" title="Division (mathematics)">division</a> in <a href="Modular_arithmetic" title="Modular arithmetic">modular arithmetic</a>. Computations using this algorithm form part of the <a href="Cryptographic_protocol" title="Cryptographic protocol">cryptographic protocols</a> that are used to secure <a href="Internet" title="Internet">internet</a> communications, and in methods for breaking these cryptosystems by <a href="Integer_factorization" title="Integer factorization">factoring large composite numbers</a>. The Euclidean algorithm may be used to solve <a href="Diophantine_equation" title="Diophantine equation">Diophantine equations</a>, such as finding numbers that satisfy multiple congruences according to the <a href="Chinese_remainder_theorem" title="Chinese remainder theorem">Chinese remainder theorem</a>, to construct <a href="Simple_continued_fraction" title="Simple continued fraction">continued fractions</a>, and to find accurate <a href="Diophantine_approximation" title="Diophantine approximation">rational approximations</a> to real numbers. Finally, it can be used as a basic tool for proving theorems in <a href="Number_theory" title="Number theory">number theory</a> such as <a href="Lagrange's_four-square_theorem" title="Lagrange's four-square theorem">Lagrange's four-square theorem</a> and the <a href="Fundamental_theorem_of_arithmetic" title="Fundamental theorem of arithmetic">uniqueness of prime factorizations</a>.
</p><p>The original algorithm was described only for natural numbers and geometric lengths (real numbers), but the algorithm was generalized in the 19th century to other types of numbers, such as <a href="Gaussian_integer" title="Gaussian integer">Gaussian integers</a> and <a href="Polynomial" title="Polynomial">polynomials</a> of one variable. This led to modern <a href="Abstract_algebra" title="Abstract algebra">abstract algebraic</a> notions such as <a href="Euclidean_domain" title="Euclidean domain">Euclidean domains</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Background:_greatest_common_divisor">Background: greatest common divisor</h2></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Greatest_common_divisor" title="Greatest common divisor">Greatest common divisor</a></div>
<p>The Euclidean algorithm calculates the greatest common divisor (GCD) of two <a href="Natural_number" title="Natural number">natural numbers</a> <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span>. The greatest common divisor <span class="texhtml mvar" style="font-style:italic;">g</span> is the largest natural number that divides both <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> without leaving a remainder. Synonyms for GCD include <i>greatest common factor</i> (GCF), <i>highest common factor</i> (HCF), <i>highest common divisor</i> (HCD), and <i>greatest common measure</i> (GCM). The greatest common divisor is often written as <span class="texhtml">gcd(<i>a</i>, <i>b</i>)</span> or, more simply, as <span class="texhtml">(<i>a</i>, <i>b</i>)</span>,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> although the latter notation is ambiguous, also used for concepts such as an <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideal</a> in the <a href="Ring_of_integers" title="Ring of integers">ring of integers</a>, which is closely related to GCD.
</p><p>If <span class="texhtml">gcd(<i>a</i>, <i>b</i>) = 1</span>, then <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> are said to be <a href="Coprime_integers" title="Coprime integers">coprime</a> (or relatively prime).<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> This property does not imply that <span class="texhtml mvar" style="font-style:italic;">a</span> or <span class="texhtml mvar" style="font-style:italic;">b</span> are themselves <a href="Prime_number" title="Prime number">prime numbers</a>.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> For example, <span class="texhtml">6</span> and <span class="texhtml">35</span> factor as <span class="texhtml">6 = 2 × 3</span> and <span class="texhtml">35 = 5 × 7</span>, so they are not prime, but their prime factors are different, so <span class="texhtml">6</span> and <span class="texhtml">35</span> are coprime, with no common factors other than&nbsp;<span class="texhtml">1</span>.
</p>

<p>Let <span class="texhtml"><i>g</i> = gcd(<i>a</i>, <i>b</i>)</span>. Since <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> are both multiples of <span class="texhtml mvar" style="font-style:italic;">g</span>, they can be written <span class="texhtml"><i>a</i> = <i>mg</i></span> and <span class="texhtml mvar" style="font-style:italic;"><i>b</i> = <i>ng</i></span>, and there is no larger number <span class="texhtml"><i>G</i> &gt; <i>g</i></span> for which this is true. The natural numbers <span class="texhtml mvar" style="font-style:italic;">m</span> and <span class="texhtml mvar" style="font-style:italic;">n</span> must be coprime, since any common factor could be factored out of <span class="texhtml mvar" style="font-style:italic;">m</span> and <span class="texhtml mvar" style="font-style:italic;">n</span> to make <span class="texhtml mvar" style="font-style:italic;">g</span> greater. Thus, any other number <span class="texhtml mvar" style="font-style:italic;">c</span> that divides both <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> must also divide <span class="texhtml mvar" style="font-style:italic;">g</span>. The greatest common divisor <span class="texhtml mvar" style="font-style:italic;">g</span> of <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> is the unique (positive) common divisor of <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> that is divisible by any other common divisor <span class="texhtml mvar" style="font-style:italic;">c</span>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>The greatest common divisor can be visualized as follows.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Consider a rectangular area <span class="texhtml mvar" style="font-style:italic;">a</span> by <span class="texhtml mvar" style="font-style:italic;">b</span>, and any common divisor <span class="texhtml mvar" style="font-style:italic;">c</span> that divides both <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> exactly. The sides of the rectangle can be divided into segments of length <span class="texhtml mvar" style="font-style:italic;">c</span>, which divides the rectangle into a grid of squares of side length <span class="texhtml mvar" style="font-style:italic;">c</span>. The GCD <span class="texhtml mvar" style="font-style:italic;">g</span> is the largest value of <span class="texhtml mvar" style="font-style:italic;">c</span> for which this is possible. For illustration, a <span class="texhtml">24×60</span> rectangular area can be divided into a grid of: <span class="texhtml">1×1</span> squares, <span class="texhtml">2×2</span> squares, <span class="texhtml">3×3</span> squares, <span class="texhtml">4×4</span> squares, <span class="texhtml">6×6</span> squares or <span class="texhtml">12×12</span> squares. Therefore, <span class="texhtml">12</span> is the GCD of <span class="texhtml">24</span> and <span class="texhtml">60</span>. A <span class="texhtml">24×60</span> rectangular area can be divided into a grid of <span class="texhtml">12×12</span> squares, with two squares along one edge (<span class="texhtml">24/12 = 2</span>) and five squares along the other (<span class="texhtml">60/12 = 5</span>).
</p><p>The greatest common divisor of two numbers <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> is the product of the prime factors shared by the two numbers, where each prime factor can be repeated as many times as it divides both <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span>.<sup id="cite_ref-Schroeder_21_9-0" class="reference"><a href="#cite_note-Schroeder_21-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> For example, since <span class="texhtml">1386</span> can be factored into <span class="texhtml">2 × 3 × 3 × 7 × 11</span>, and <span class="texhtml">3213</span> can be factored into <span class="texhtml">3 × 3 × 3 × 7 × 17</span>, the GCD of <span class="texhtml">1386</span> and <span class="texhtml">3213</span> equals <span class="texhtml">63 = 3 × 3 × 7</span>, the product of their shared prime factors (with 3 repeated since <span class="texhtml">3 × 3</span> divides both). If two numbers have no common prime factors, their GCD is <span class="texhtml">1</span> (obtained here as an instance of the <a href="Empty_product" title="Empty product">empty product</a>); in other words, they are coprime. A key advantage of the Euclidean algorithm is that it can find the GCD efficiently without having to compute the prime factors.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> <a href="Integer_factorization" title="Integer factorization">Factorization</a> of large integers is believed to be a computationally very difficult problem, and the security of many widely used <a href="Cryptographic_protocol" title="Cryptographic protocol">cryptographic protocols</a> is based upon its infeasibility.<sup id="cite_ref-Schroeder_216_12-0" class="reference"><a href="#cite_note-Schroeder_216-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p><p>Another definition of the GCD is helpful in advanced mathematics, particularly <a href="Ring_theory" title="Ring theory">ring theory</a>.<sup id="cite_ref-Leveque_p33_13-0" class="reference"><a href="#cite_note-Leveque_p33-13"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> The greatest common divisor <span class="texhtml mvar" style="font-style:italic;">g</span> of two nonzero numbers <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> is also their smallest positive integral linear combination, that is, the smallest positive number of the form <span class="texhtml"><i>ua</i> + <i>vb</i></span> where <span class="texhtml mvar" style="font-style:italic;">u</span> and <span class="texhtml mvar" style="font-style:italic;">v</span> are integers. The set of all integral linear combinations of <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> is actually the same as the set of all multiples of <span class="texhtml mvar" style="font-style:italic;">g</span> (<span class="texhtml mvar" style="font-style:italic;">mg</span>, where <span class="texhtml mvar" style="font-style:italic;">m</span> is an integer). In modern mathematical language, the <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideal</a> generated by <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> is the ideal generated by&nbsp;<span class="texhtml mvar" style="font-style:italic;">g</span> alone (an ideal generated by a single element is called a <a href="Principal_ideal" title="Principal ideal">principal ideal</a>, and all ideals of the integers are principal ideals). Some properties of the GCD are in fact easier to see with this description, for instance the fact that any common divisor of <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> also divides the GCD (it divides both terms of <span class="texhtml"><i>ua</i>&nbsp;+&nbsp;<i>vb</i></span>). The equivalence of this GCD definition with the other definitions is described below.
</p><p>The GCD of three or more numbers equals the product of the prime factors common to all the numbers,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> but it can also be calculated by repeatedly taking the GCDs of pairs of numbers.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> For example,
</p>
<dl><dd><span class="texhtml">gcd(<i>a</i>, <i>b</i>, <i>c</i>) = gcd(<i>a</i>, gcd(<i>b</i>, <i>c</i>)) = gcd(gcd(<i>a</i>, <i>b</i>), <i>c</i>) = gcd(gcd(<i>a</i>, <i>c</i>), <i>b</i>).</span></dd></dl>
<p>Thus, Euclid's algorithm, which computes the GCD of two integers, suffices to calculate the GCD of arbitrarily many integers.
</p>
<div class="mw-heading mw-heading3"><h3 id="Procedure">Procedure</h3></div>
<div class="euclidean-algorithm-steps calculator-container calculatorgadget-enabled" style="border: 1px solid #a2a9b1; background-color: var(--background-color-neutral-subtle, #f8f9fa); color: inherit; margin: 0.5em 0 0.5em 1em; padding: 0.5em; float: right; clear: right; font-size: 88%; line-height: 1.5em; width: 22em; display:none;" data-calculator-refresh-on-load="true"><b>Compute the Euclidean algorithm step by step</b><br>
<p><style data-mw-deduplicate="TemplateStyles:r1257291628">
/* start https://en.wikipedia.org/ */


.mw-parser-output .calculator-hideifzero.calculator-value-false{display:none}


/* end https://en.wikipedia.org/ */
</style><span class="calculator-field calculator-hideifzero" data-calculator-type="passthru" data-calculator-formula="ifequal(curstep,-1)"><span class="calculator-field-label" data-for="calculator-field-x">a =</span> <span class="calculator-field" id="calculator-field-x" data-calculator-type="number" data-calculator-size="4">1071</span>; <span class="calculator-field-label" data-for="calculator-field-y">b =</span> <span class="calculator-field" id="calculator-field-y" data-calculator-type="number" data-calculator-size="4">462</span></span>
<span class="calculator-field calculator-hideifzero" data-calculator-type="passthru" data-calculator-formula="not(ifequal(curstep,-1))"><span class="texhtml">a = <span class="calculator-field" data-calculator-type="plain" style="background-color: light-dark( hsl(55,100%,70%,var(--calculator-colorstep0)), hsl(55,100%,25%,var(--calculator-colorstep0)) ); color: inherit" data-calculator-formula="r0" data-calculator-size="4">119</span></span>; <span class="texhtml">b = <span class="calculator-field" data-calculator-type="plain" style="background-color: light-dark( hsl(155,100%,70%,var(--calculator-colorstep0)), hsl(155,100%,25%,var(--calculator-colorstep0)) ); color: inherit" data-calculator-formula="r1" data-calculator-size="4">61</span></span></span>

</p>
<span class="calculator-field" id="calculator-field-curstep" data-calculator-type="hidden" style="display:none;display:none">-1</span><div role="log">
<span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,0,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"> = q<sub>0</sub> × + r<sub>0</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,1,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>0</sub> = ; r<sub>0</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r2),ifgreaterorequal(curstep,1,1,0))"><br>Since <span class="texhtml">r<sub>0</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,2,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>1</sub> × + r<sub>1</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,3,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>1</sub> = ; r<sub>1</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r3),ifgreaterorequal(curstep,3,1,0))"><br>Since <span class="texhtml">r<sub>1</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,4,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>2</sub> × + r<sub>2</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,5,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>2</sub> = ; r<sub>2</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r4),ifgreaterorequal(curstep,5,1,0))"><br>Since <span class="texhtml">r<sub>2</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,6,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>3</sub> × + r<sub>3</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,7,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>3</sub> = ; r<sub>3</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r5),ifgreaterorequal(curstep,7,1,0))"><br>Since <span class="texhtml">r<sub>3</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,8,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>4</sub> × + r<sub>4</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,9,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>4</sub> = ; r<sub>4</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r6),ifgreaterorequal(curstep,9,1,0))"><br>Since <span class="texhtml">r<sub>4</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,10,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>5</sub> × + r<sub>5</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,11,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>5</sub> = ; r<sub>5</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r7),ifgreaterorequal(curstep,11,1,0))"><br>Since <span class="texhtml">r<sub>5</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,12,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>6</sub> × + r<sub>6</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,13,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>6</sub> = ; r<sub>6</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r8),ifgreaterorequal(curstep,13,1,0))"><br>Since <span class="texhtml">r<sub>6</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,14,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>7</sub> × + r<sub>7</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,15,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>7</sub> = ; r<sub>7</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r9),ifgreaterorequal(curstep,15,1,0))"><br>Since <span class="texhtml">r<sub>7</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,16,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>8</sub> × + r<sub>8</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,17,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>8</sub> = ; r<sub>8</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r10),ifgreaterorequal(curstep,17,1,0))"><br>Since <span class="texhtml">r<sub>8</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,18,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>9</sub> × + r<sub>9</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,19,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>9</sub> = ; r<sub>9</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r11),ifgreaterorequal(curstep,19,1,0))"><br>Since <span class="texhtml">r<sub>9</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,20,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true"><hr> = q<sub>10</sub> × + r<sub>10</sub><br></span><span class="calculator-field calculator-hideifzero calculator-value-false texhtml" data-calculator-type="passthru" data-calculator-formula="ifgreaterorequal(curstep,21,1,0)" data-calculator-aria-live="polite" data-calculator-aria-atomic="true">q<sub>10</sub> = ; r<sub>10</sub> = </span><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="and(not(r12),ifgreaterorequal(curstep,21,1,0))"><br>Since <span class="texhtml">r<sub>10</sub> = 0</span> the algorithm is finished. Thus <b><span class="texhtml">GCD( , ) = </span></b>.</span>
<span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="ifgreater(curstep,21)"><span class="error">Number is too big for the calculator</span></span></div>
<p><span class="calculator-field calculator-hideifzero calculator-value-false" data-calculator-type="passthru" data-calculator-formula="ifgreater(curstep,-1)"><span class="calculator-field-button cdx-button cdx-button--action-destructive cdx-button--weight-normal cdx-button--size-medium" data-calculator-for="curstep" data-calculator-formula="-1">Restart</span></span> <span class="calculator-field calculator-hideifzero" data-calculator-type="passthru" data-calculator-formula="or( and( ifequal(curstep%2,0), ifless(curstep,21 ) ), and( ifbetween(curstep,-1,21), not( ifequal( index(r,(curstep-1)/2+2), 0 ) ), ifequal( curstep,1,r1,1 ) ) )"><span class="calculator-field-button cdx-button cdx-button--action-progressive cdx-button--weight-primary cdx-button--size-medium" style="cursor:pointer" data-calculator-for="curstep" data-calculator-formula="curstep+1"><span class="calculator-field" data-calculator-type="plain" data-calculator-formula="curstep" data-calculator-mapping="{&quot;Next →&quot;:&quot;default&quot;,&quot;Start&quot;:-1}">Start</span></span></span>
</p>
</div>
<p>The Euclidean algorithm can be thought of as constructing a sequence of non-negative integers that begins with the two given integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{-2}=a}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>a</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{-2}=a}</annotation>
</semantics>
</math></span><img src="./4b0136faf86219f470fb2e7ce19768e6cce4444d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.71ex; height:2.009ex;" alt="{\displaystyle r_{-2}=a}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{-1}=b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{-1}=b}</annotation>
</semantics>
</math></span><img src="./6c050066bdeed7fdaabfe541629f843e6516e1e7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.477ex; height:2.509ex;" alt="{\displaystyle r_{-1}=b}" loading="lazy"></span> and will eventually terminate with the integer zero: <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{r_{-2}=a,\ r_{-1}=b,\ r_{0},\ r_{1},\ \cdots ,\ r_{n-1},\ r_{n}=0\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>b</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mo>⋯<!-- ⋯ --></mo>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</msub>
<mo>=</mo>
<mn>0</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{r_{-2}=a,\ r_{-1}=b,\ r_{0},\ r_{1},\ \cdots ,\ r_{n-1},\ r_{n}=0\}}</annotation>
</semantics>
</math></span><img src="./88b215f1f4abd9a17e40896b538e62df052900f9.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:45.798ex; height:2.843ex;" alt="{\displaystyle \{r_{-2}=a,\ r_{-1}=b,\ r_{0},\ r_{1},\ \cdots ,\ r_{n-1},\ r_{n}=0\}}" loading="lazy"></span> with <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k+1}<r_{k}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k+1}&lt;r_{k}}</annotation>
</semantics>
</math></span><img src="./0050bd8ca461f3a4281bfee17c22e13f42666d44.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:9.474ex; height:2.176ex;" alt="{\displaystyle r_{k+1}<r_{k}}" loading="lazy"></span>. The integer <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{n-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{n-1}}</annotation>
</semantics>
</math></span><img src="./1bb9423fd6766c31baf0369064fcf25ea2b1f584.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.368ex; height:2.009ex;" alt="{\displaystyle r_{n-1}}" loading="lazy"></span> will then be the GCD and we can state <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\text{gcd}}(a,b)=r_{n-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtext>gcd</mtext>
</mrow>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\text{gcd}}(a,b)=r_{n-1}}</annotation>
</semantics>
</math></span><img src="./96158621032c947e43bfb4c168d7ff905cd33caa.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:16.024ex; height:2.843ex;" alt="{\displaystyle {\text{gcd}}(a,b)=r_{n-1}}" loading="lazy"></span>. The algorithm indicates how to construct the intermediate remainders <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k}}</annotation>
</semantics>
</math></span><img src="./9b28e0e640d099f3676330bd4f604ae15c37bb4f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.137ex; height:2.009ex;" alt="{\displaystyle r_{k}}" loading="lazy"></span> via <a href="Euclidean_division" title="Euclidean division">division-with-remainder</a> on the preceding pair <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (r_{k-2},\ r_{k-1})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo stretchy="false">(</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle (r_{k-2},\ r_{k-1})}</annotation>
</semantics>
</math></span><img src="./cd0040f143b057dfaec76c8060a58b9e3c19d52d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:11.9ex; height:2.843ex;" alt="{\displaystyle (r_{k-2},\ r_{k-1})}" loading="lazy"></span> by finding an integer quotient <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{k}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{k}}</annotation>
</semantics>
</math></span><img src="./f27215e46abcad60f100434d2c8003310580af95.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.126ex; height:2.009ex;" alt="{\displaystyle q_{k}}" loading="lazy"></span> so that:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k-2}=q_{k}\cdot r_{k-1}+r_{k}{\text{, with }}\ r_{k-1}>r_{k}\geq 0.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mrow class="MJX-TeXAtom-ORD">
<mtext>, with&nbsp;</mtext>
</mrow>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>&gt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>≥<!-- ≥ --></mo>
<mn>0.</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k-2}=q_{k}\cdot r_{k-1}+r_{k}{\text{, with }}\ r_{k-1}&gt;r_{k}\geq 0.}</annotation>
</semantics>
</math></span><img src="./b5f11ad02814d92f80b7dc1c51417700678cd9c4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:41.649ex; height:2.509ex;" alt="{\displaystyle r_{k-2}=q_{k}\cdot r_{k-1}+r_{k}{\text{, with }}\ r_{k-1}>r_{k}\geq 0.}" loading="lazy"></span></dd></dl>
<p>Because the sequence of non-negative integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{r_{k}\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{r_{k}\}}</annotation>
</semantics>
</math></span><img src="./8b17ba8cd3cd568f36a3e47f2d0b1b318e5c2c9f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.462ex; height:2.843ex;" alt="{\displaystyle \{r_{k}\}}" loading="lazy"></span> is strictly decreasing, it eventually <a href="Well-ordering_principle" title="Well-ordering principle">must terminate</a>. In other words, since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k}\geq 0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>≥<!-- ≥ --></mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k}\geq 0}</annotation>
</semantics>
</math></span><img src="./88bee94c4dd17b9202cc261159e77292e1a5d535.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.398ex; height:2.509ex;" alt="{\displaystyle r_{k}\geq 0}" loading="lazy"></span> for every <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k}</annotation>
</semantics>
</math></span><img src="./c3c9a2c7b599b37105512c5d570edc034056dd40.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.211ex; height:2.176ex;" alt="{\displaystyle k}" loading="lazy"></span>, and each <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k}}</annotation>
</semantics>
</math></span><img src="./9b28e0e640d099f3676330bd4f604ae15c37bb4f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.137ex; height:2.009ex;" alt="{\displaystyle r_{k}}" loading="lazy"></span> is an integer that is strictly smaller than the preceding <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k-1}}</annotation>
</semantics>
</math></span><img src="./2dbe2626d424eb6b58b44a40172092dc04b16928.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.238ex; height:2.009ex;" alt="{\displaystyle r_{k-1}}" loading="lazy"></span>, there eventually cannot be a non-negative integer smaller than zero, and hence the algorithm must terminate. In fact, the algorithm will always terminate at the <span class="texhtml"><i>n</i></span>th step with <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{n}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{n}}</annotation>
</semantics>
</math></span><img src="./57784cdf7f49f2c46baad4eb7b6a7d5c14eb5fa4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.267ex; height:2.009ex;" alt="{\displaystyle r_{n}}" loading="lazy"></span> equal to zero.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</p><p>To illustrate, suppose the GCD of 1071 and 462 is requested. The sequence is initially <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{r_{-2}=1071,\ r_{-1}=462\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>1071</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>462</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{r_{-2}=1071,\ r_{-1}=462\}}</annotation>
</semantics>
</math></span><img src="./d13bb0c5e0679933d256a47f508d4520436a1293.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:25.036ex; height:2.843ex;" alt="{\displaystyle \{r_{-2}=1071,\ r_{-1}=462\}}" loading="lazy"></span> and in order to find <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{0}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{0}}</annotation>
</semantics>
</math></span><img src="./fb12fcfddb65e3d1e6a044215f6e833f0cd4337b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.103ex; height:2.009ex;" alt="{\displaystyle r_{0}}" loading="lazy"></span>, we need to find integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{0}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{0}}</annotation>
</semantics>
</math></span><img src="./9d68d37de188ac61f0c0e3f31d5322d1c486f2f4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.091ex; height:2.009ex;" alt="{\displaystyle q_{0}}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{0}<r_{-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{0}&lt;r_{-1}}</annotation>
</semantics>
</math></span><img src="./b9881df9fbb3f2e6f2c2ce60f80163ca9c1b79f0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:8.583ex; height:2.176ex;" alt="{\displaystyle r_{0}<r_{-1}}" loading="lazy"></span> such that:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1071=q_{0}\cdot 462+r_{0}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>1071</mn>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<mn>462</mn>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1071=q_{0}\cdot 462+r_{0}}</annotation>
</semantics>
</math></span><img src="./134fcdcde86566150a6ea0c4a67edcfa009a104d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:19.949ex; height:2.509ex;" alt="{\displaystyle 1071=q_{0}\cdot 462+r_{0}}" loading="lazy"></span>.</dd></dl>
<p>This is the quotient <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{0}=2}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>2</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{0}=2}</annotation>
</semantics>
</math></span><img src="./01aeacf38388c22735226bf7984fa4e0421567a2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.352ex; height:2.509ex;" alt="{\displaystyle q_{0}=2}" loading="lazy"></span> since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1071=2\cdot 462+147}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>1071</mn>
<mo>=</mo>
<mn>2</mn>
<mo>⋅<!-- ⋅ --></mo>
<mn>462</mn>
<mo>+</mo>
<mn>147</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1071=2\cdot 462+147}</annotation>
</semantics>
</math></span><img src="./94c999621b3352671d75af5a38849325a1eb48aa.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:20.405ex; height:2.343ex;" alt="{\displaystyle 1071=2\cdot 462+147}" loading="lazy"></span>. This determines <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{0}=147}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>147</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{0}=147}</annotation>
</semantics>
</math></span><img src="./5b4e0635872f040ead64628f6a9e9f485f8b2233.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:8.689ex; height:2.509ex;" alt="{\displaystyle r_{0}=147}" loading="lazy"></span> and so the sequence is now <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{1071,\ 462,\ r_{0}=147\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mn>1071</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>462</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>147</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{1071,\ 462,\ r_{0}=147\}}</annotation>
</semantics>
</math></span><img src="./cdd3b0efd9b16dc223104d6e041f3afba0c06837.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:22.38ex; height:2.843ex;" alt="{\displaystyle \{1071,\ 462,\ r_{0}=147\}}" loading="lazy"></span>. The next step is to continue the sequence to find <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{1}}</annotation>
</semantics>
</math></span><img src="./ea214f2b31fb3869344bb9311da41c5cc38a99e1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.103ex; height:2.009ex;" alt="{\displaystyle r_{1}}" loading="lazy"></span> by finding integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{1}}</annotation>
</semantics>
</math></span><img src="./9daa41f6e8f78ea6bb5711d7ac97901ce564b94e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.091ex; height:2.009ex;" alt="{\displaystyle q_{1}}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{1}<r_{0}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{1}&lt;r_{0}}</annotation>
</semantics>
</math></span><img src="./b12c3a286a4d3bb52192f55f84a19d8fd9ddcf15.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.304ex; height:2.176ex;" alt="{\displaystyle r_{1}<r_{0}}" loading="lazy"></span> such that:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 462=q_{1}\cdot 147+r_{1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>462</mn>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<mn>147</mn>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 462=q_{1}\cdot 147+r_{1}}</annotation>
</semantics>
</math></span><img src="./eb18f88782e8818d4e16a2ac2ac794be65812ddc.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:18.787ex; height:2.509ex;" alt="{\displaystyle 462=q_{1}\cdot 147+r_{1}}" loading="lazy"></span>.</dd></dl>
<p>This is the quotient <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{1}=3}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>3</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{1}=3}</annotation>
</semantics>
</math></span><img src="./b2a6116e2c4a858aaf540d51e4e66f7ffd71910e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.352ex; height:2.509ex;" alt="{\displaystyle q_{1}=3}" loading="lazy"></span> since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 462=3\cdot 147+21}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>462</mn>
<mo>=</mo>
<mn>3</mn>
<mo>⋅<!-- ⋅ --></mo>
<mn>147</mn>
<mo>+</mo>
<mn>21</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 462=3\cdot 147+21}</annotation>
</semantics>
</math></span><img src="./e8dd01e2e052d1e21527bf9cf2ccaa137ad088e1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:18.08ex; height:2.343ex;" alt="{\displaystyle 462=3\cdot 147+21}" loading="lazy"></span>. This determines <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{1}=21}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>21</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{1}=21}</annotation>
</semantics>
</math></span><img src="./d76ce06c8842f345132606a468f41bfc181ce02b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.526ex; height:2.509ex;" alt="{\displaystyle r_{1}=21}" loading="lazy"></span> and so the sequence is now <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{1071,\ 462,\ 147,\ r_{1}=21\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mn>1071</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>462</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>147</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>21</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{1071,\ 462,\ 147,\ r_{1}=21\}}</annotation>
</semantics>
</math></span><img src="./377419d7664d8d9ab5a3fe736161190b9d4a14d9.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:26.319ex; height:2.843ex;" alt="{\displaystyle \{1071,\ 462,\ 147,\ r_{1}=21\}}" loading="lazy"></span>. The next step is to continue the sequence to find <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{2}}</annotation>
</semantics>
</math></span><img src="./4cbe9b0b294fdd6fadbf9a7249813f016dcbc44f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.103ex; height:2.009ex;" alt="{\displaystyle r_{2}}" loading="lazy"></span> by finding integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{2}}</annotation>
</semantics>
</math></span><img src="./fd2d05084feb02b8ba29b0673440fb673b102589.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.091ex; height:2.009ex;" alt="{\displaystyle q_{2}}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{2}<r_{1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{2}&lt;r_{1}}</annotation>
</semantics>
</math></span><img src="./0d285ffc35d03cc59b9248ef1aba3aca1db3c1e2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.304ex; height:2.176ex;" alt="{\displaystyle r_{2}<r_{1}}" loading="lazy"></span> such that:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 147=q_{2}\cdot 21+r_{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>147</mn>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<mn>21</mn>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 147=q_{2}\cdot 21+r_{2}}</annotation>
</semantics>
</math></span><img src="./00aa855c57184d1893bbadf26f03fe81af5f58c1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:17.624ex; height:2.509ex;" alt="{\displaystyle 147=q_{2}\cdot 21+r_{2}}" loading="lazy"></span>.</dd></dl>
<p>This is the quotient <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q_{2}=7}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>7</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle q_{2}=7}</annotation>
</semantics>
</math></span><img src="./b9cedb62a43694c72c63d5111ec2abf553acca77.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.352ex; height:2.509ex;" alt="{\displaystyle q_{2}=7}" loading="lazy"></span> since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 147=7\cdot 21+0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>147</mn>
<mo>=</mo>
<mn>7</mn>
<mo>⋅<!-- ⋅ --></mo>
<mn>21</mn>
<mo>+</mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 147=7\cdot 21+0}</annotation>
</semantics>
</math></span><img src="./42e87dc6e6fe5d1f6423040fd2da30926e37a486.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:15.755ex; height:2.343ex;" alt="{\displaystyle 147=7\cdot 21+0}" loading="lazy"></span>. This determines <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{2}=0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{2}=0}</annotation>
</semantics>
</math></span><img src="./72f6b52dcbeb88769147b35e6edd21b698301547.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.364ex; height:2.509ex;" alt="{\displaystyle r_{2}=0}" loading="lazy"></span> and so the sequence is completed as <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{1071,\ 462,\ 147,\ 21,\ r_{2}=0\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mn>1071</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>462</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>147</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>21</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>=</mo>
<mn>0</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{1071,\ 462,\ 147,\ 21,\ r_{2}=0\}}</annotation>
</semantics>
</math></span><img src="./9bf735b01cff1ed6b55ce0abc98f8f2988905728.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:29.097ex; height:2.843ex;" alt="{\displaystyle \{1071,\ 462,\ 147,\ 21,\ r_{2}=0\}}" loading="lazy"></span> as no further non-negative integer smaller than <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 0}</annotation>
</semantics>
</math></span><img src="./2aae8864a3c1fec9585261791a809ddec1489950.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.162ex; height:2.176ex;" alt="{\displaystyle 0}" loading="lazy"></span> can be found. The penultimate remainder <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 21}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>21</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 21}</annotation>
</semantics>
</math></span><img src="./77ebb9ccf6080ba5c9a6ea8973cb2f26c50211cf.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.325ex; height:2.176ex;" alt="{\displaystyle 21}" loading="lazy"></span> is therefore the requested GCD:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\text{gcd}}(1071,\ 462)=21.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtext>gcd</mtext>
</mrow>
<mo stretchy="false">(</mo>
<mn>1071</mn>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>462</mn>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mn>21.</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\text{gcd}}(1071,\ 462)=21.}</annotation>
</semantics>
</math></span><img src="./cd300bc3002d80df5682f917dd715d459f8217cc.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:21.119ex; height:2.843ex;" alt="{\displaystyle {\text{gcd}}(1071,\ 462)=21.}" loading="lazy"></span></dd></dl>
<p>We can generalize slightly by dropping any ordering requirement on the initial two values <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a}</annotation>
</semantics>
</math></span><img src="./ffd2487510aa438433a2579450ab2b3d557e5edc.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.23ex; height:1.676ex;" alt="{\displaystyle a}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle b}</annotation>
</semantics>
</math></span><img src="./f11423fbb2e967f986e36804a8ae4271734917c3.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:0.998ex; height:2.176ex;" alt="{\displaystyle b}" loading="lazy"></span>. If <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a=b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
<mo>=</mo>
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a=b}</annotation>
</semantics>
</math></span><img src="./1956b03d1314c7071ac1f45ed7b1e29422dcfcc4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.326ex; height:2.176ex;" alt="{\displaystyle a=b}" loading="lazy"></span>, the algorithm may continue and trivially find that <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\text{gcd}}(a,\ a)=a}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtext>gcd</mtext>
</mrow>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>a</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\text{gcd}}(a,\ a)=a}</annotation>
</semantics>
</math></span><img src="./fad3c75dee86381c3e7294b138cb04e32fe73783.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.699ex; height:2.843ex;" alt="{\displaystyle {\text{gcd}}(a,\ a)=a}" loading="lazy"></span> as the sequence of remainders will be <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{a,\ a,\ 0\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mn>0</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{a,\ a,\ 0\}}</annotation>
</semantics>
</math></span><img src="./0dd9b227019fa9774e888298439ac8590061ed13.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.176ex; height:2.843ex;" alt="{\displaystyle \{a,\ a,\ 0\}}" loading="lazy"></span>. If <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a<b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
<mo>&lt;</mo>
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a&lt;b}</annotation>
</semantics>
</math></span><img src="./91a7698e4c7401bb321f97888b872b583a9e4642.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.326ex; height:2.176ex;" alt="{\displaystyle a<b}" loading="lazy"></span>, then we can also continue since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a\equiv 0\cdot b+a}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
<mo>≡<!-- ≡ --></mo>
<mn>0</mn>
<mo>⋅<!-- ⋅ --></mo>
<mi>b</mi>
<mo>+</mo>
<mi>a</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a\equiv 0\cdot b+a}</annotation>
</semantics>
</math></span><img src="./fc32682dc755734e0b01e1fc2e0cbb81e1b9e1b4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:12.238ex; height:2.343ex;" alt="{\displaystyle a\equiv 0\cdot b+a}" loading="lazy"></span>, suggesting the next remainder should be <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a}</annotation>
</semantics>
</math></span><img src="./ffd2487510aa438433a2579450ab2b3d557e5edc.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.23ex; height:1.676ex;" alt="{\displaystyle a}" loading="lazy"></span> itself, and the sequence is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{a,\ b,\ a,\ \cdots \}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mi>b</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mi>a</mi>
<mo>,</mo>
<mtext>&nbsp;</mtext>
<mo>⋯<!-- ⋯ --></mo>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{a,\ b,\ a,\ \cdots \}}</annotation>
</semantics>
</math></span><img src="./13e8ec985de11109fdd5ef818058b27c909f3222.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.736ex; height:2.843ex;" alt="{\displaystyle \{a,\ b,\ a,\ \cdots \}}" loading="lazy"></span>. Normally, this would be invalid because it breaks the requirement <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{0}<r_{-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{0}&lt;r_{-1}}</annotation>
</semantics>
</math></span><img src="./b9881df9fbb3f2e6f2c2ce60f80163ca9c1b79f0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:8.583ex; height:2.176ex;" alt="{\displaystyle r_{0}<r_{-1}}" loading="lazy"></span> but now we have <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a<b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
<mo>&lt;</mo>
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a&lt;b}</annotation>
</semantics>
</math></span><img src="./91a7698e4c7401bb321f97888b872b583a9e4642.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.326ex; height:2.176ex;" alt="{\displaystyle a<b}" loading="lazy"></span> by construction, so the requirement is automatically satisfied and the Euclidean algorithm can continue as normal. Therefore, dropping any ordering between the first two integers does not affect the conclusion that the sequence must eventually terminate because the next remainder will always satisfy <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{0}<b}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>&lt;</mo>
<mi>b</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{0}&lt;b}</annotation>
</semantics>
</math></span><img src="./cee19f7a6468daf3449129c0da9cd74c60907870.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:6.199ex; height:2.509ex;" alt="{\displaystyle r_{0}<b}" loading="lazy"></span> and everything continues as above. The only modifications that need to be made are that <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k}<r_{k-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>&lt;</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k}&lt;r_{k-1}}</annotation>
</semantics>
</math></span><img src="./7fef79fa31424b1f2f75ab8680ce6c99967dd167.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:9.474ex; height:2.176ex;" alt="{\displaystyle r_{k}<r_{k-1}}" loading="lazy"></span> only for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k\geq 0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
<mo>≥<!-- ≥ --></mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k\geq 0}</annotation>
</semantics>
</math></span><img src="./79214ef55efadfb1d9c9b02252eb8a71cf6f8b6b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.472ex; height:2.343ex;" alt="{\displaystyle k\geq 0}" loading="lazy"></span>, and that the sub-sequence of non-negative integers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{r_{k-1}\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{r_{k-1}\}}</annotation>
</semantics>
</math></span><img src="./9f241182d363fb5368558a99442e54504cb2a065.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:6.563ex; height:2.843ex;" alt="{\displaystyle \{r_{k-1}\}}" loading="lazy"></span> for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k\geq 0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
<mo>≥<!-- ≥ --></mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k\geq 0}</annotation>
</semantics>
</math></span><img src="./79214ef55efadfb1d9c9b02252eb8a71cf6f8b6b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.472ex; height:2.343ex;" alt="{\displaystyle k\geq 0}" loading="lazy"></span> is strictly decreasing, therefore excluding <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a=r_{-2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>a</mi>
<mo>=</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a=r_{-2}}</annotation>
</semantics>
</math></span><img src="./965ed3d75ce7948e5fe434ec6f79dcbaf252b119.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.71ex; height:2.009ex;" alt="{\displaystyle a=r_{-2}}" loading="lazy"></span> from both statements.
</p>
<div class="mw-heading mw-heading3"><h3 id="Proof_of_validity">Proof of validity</h3></div>
<p>The validity of the Euclidean algorithm can be proven by a two-step argument.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup> In the first step, the final nonzero remainder <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> is shown to divide both <span class="texhtml"><i>a</i></span> and&nbsp;<span class="texhtml"><i>b</i></span>. Since it is a common divisor, it must be less than or equal to the greatest common divisor&nbsp;<span class="texhtml"><i>g</i></span>. In the second step, it is shown that any common divisor of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>, including&nbsp;<span class="texhtml"><i>g</i></span>, must divide <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span>; therefore, <span class="texhtml"><i>g</i></span> must be less than or equal to <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span>. These two opposite inequalities imply <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub> = <i>g</i></span>.
</p><p>To demonstrate that <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> divides both <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> (the first step), <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> divides its predecessor <span class="texhtml"><i>r</i><sub><i>N</i>−2</sub></span>
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>N</i>−2</sub> = <i>q</i><sub><i>N</i></sub> <i>r</i><sub><i>N</i>−1</sub></span></dd></dl>
<p>since the final remainder <span class="texhtml"><i>r</i><sub><i>N</i></sub></span> is zero. <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> also divides its next predecessor <span class="texhtml"><i>r</i><sub><i>N</i>−3</sub></span>
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>N</i>−3</sub> = <i>q</i><sub><i>N</i>−1</sub> <i>r</i><sub><i>N</i>−2</sub> + <i>r</i><sub><i>N</i>−1</sub></span></dd></dl>
<p>because it divides both terms on the right-hand side of the equation. Iterating the same argument, <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> divides all the preceding remainders, including <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>. None of the preceding remainders <span class="texhtml"><i>r</i><sub><i>N</i>−2</sub></span>, <span class="texhtml"><i>r</i><sub><i>N</i>−3</sub></span>, etc. divide <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>, since they leave a remainder. Since <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span> is a common divisor of <span class="texhtml"><i>a</i></span> and&nbsp;<span class="texhtml"><i>b</i></span>, <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub> ≤ <i>g</i></span>.
</p><p>In the second step, any natural number <span class="texhtml"><i>c</i></span> that divides both <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> (in other words, any common divisor of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>) divides the remainders <span class="texhtml"><i>r</i><sub><i>k</i></sub></span>. By definition, <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> can be written as multiples of <span class="texhtml"><i>c</i></span>: <span class="texhtml"><i>a</i> = <i>mc</i></span> and <span class="texhtml"><i>b</i> = <i>nc</i></span>, where <span class="texhtml"><i>m</i></span> and <span class="texhtml"><i>n</i></span> are natural numbers. Therefore, <span class="texhtml"><i>c</i></span> divides the initial remainder <span class="texhtml"><i>r</i><sub>0</sub></span>, since <span class="texhtml"><i>r</i><sub>0</sub> = <i>a</i> − <i>q</i><sub>0</sub><i>b</i> = <i>mc</i> − <i>q</i><sub>0</sub><i>nc</i> = (<i>m</i> − <i>q</i><sub>0</sub><i>n</i>)<i>c</i></span>. An analogous argument shows that <span class="texhtml"><i>c</i></span> also divides the subsequent remainders <span class="texhtml"><i>r</i><sub>1</sub></span>, <span class="texhtml"><i>r</i><sub>2</sub></span>, etc. Therefore, the greatest common divisor <span class="texhtml"><i>g</i></span> must divide <span class="texhtml"><i>r</i><sub><i>N</i>−1</sub></span>, which implies that <span class="texhtml"><i>g</i> ≤ <i>r</i><sub><i>N</i>−1</sub></span>. Since the first part of the argument showed the reverse (<span class="texhtml"><i>r</i><sub><i>N</i>−1</sub> ≤ <i>g</i></span>), it follows that <span class="texhtml"><i>g</i> = <i>r</i><sub><i>N</i>−1</sub></span>. Thus, <span class="texhtml"><i>g</i></span> is the greatest common divisor of all the succeeding pairs:<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Lovasz_2003_19-0" class="reference"><a href="#cite_note-Lovasz_2003-19"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle g=\gcd(a,b)=\gcd(a,r_{0})=\gcd(r_{0},r_{1})=\dots =\gcd(r_{k-1},r_{k})=\dots =\gcd(r_{N-2},r_{N-1})=\gcd(r_{N-1},0)=r_{N-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>g</mi>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>,</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>,</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
<mo>=</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle g=\gcd(a,b)=\gcd(a,r_{0})=\gcd(r_{0},r_{1})=\dots =\gcd(r_{k-1},r_{k})=\dots =\gcd(r_{N-2},r_{N-1})=\gcd(r_{N-1},0)=r_{N-1}}</annotation>
</semantics>
</math></span><img src="./7e666e8ff40bc7eaeb875386098edb5306036a0c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:109.098ex; height:2.843ex;" alt="{\displaystyle g=\gcd(a,b)=\gcd(a,r_{0})=\gcd(r_{0},r_{1})=\dots =\gcd(r_{k-1},r_{k})=\dots =\gcd(r_{N-2},r_{N-1})=\gcd(r_{N-1},0)=r_{N-1}}" loading="lazy"></span></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Worked_example">Worked example</h3></div>

<p>For illustration, the Euclidean algorithm can be used to find the greatest common divisor of <span class="texhtml"><i>a</i> = 1071</span> and <span class="texhtml"><i>b</i> = 462</span>. To begin, multiples of <span class="texhtml">462</span> are subtracted from <span class="texhtml">1071</span> until the remainder is less than <span class="texhtml">462</span>. Two such multiples can be subtracted (<span class="texhtml"><i>q</i><sub>0</sub> = 2</span>), leaving a remainder of <span class="texhtml">147</span>:
</p>
<dl><dd><span class="texhtml">1071 = 2 × 462 + 147</span>.</dd></dl>
<p>Then multiples of <span class="texhtml">147</span> are subtracted from <span class="texhtml">462</span> until the remainder is less than <span class="texhtml">147</span>. Three multiples can be subtracted (<span class="texhtml"><i>q</i><sub>1</sub> = 3</span>), leaving a remainder of <span class="texhtml">21</span>:
</p>
<dl><dd><span class="texhtml">462 = 3 × 147 + 21</span>.</dd></dl>
<p>Then multiples of <span class="texhtml">21</span> are subtracted from <span class="texhtml">147</span> until the remainder is less than <span class="texhtml">21</span>. Seven multiples can be subtracted (<span class="texhtml"><i>q</i><sub>2</sub> = 7</span>), leaving no remainder:
</p>
<dl><dd><span class="texhtml">147 = 7 × 21 + 0</span>.</dd></dl>
<p>Since the last remainder is zero, the algorithm ends with <span class="texhtml">21</span> as the greatest common divisor of <span class="texhtml">1071</span> and <span class="texhtml">462</span>. This agrees with the <span class="texhtml">gcd(1071, 462)</span> found by prime factorization <a href="#Background:_greatest_common_divisor">above</a>. In tabular form, the steps are:
</p>
<table class="wikitable" id="basic_Euclidean_algorithm" style="margin-left:auto; margin-right:auto; text-align:center">

<tbody><tr>
<th>Step <i>k</i></th>
<th>Equation</th>
<th>Quotient and remainder
</th></tr>
<tr>
<td>0</td>
<td><span class="texhtml">1071 = <i>q</i><sub>0</sub> 462 + <i>r</i><sub>0</sub></span></td>
<td><span class="texhtml"><i>q</i><sub>0</sub> = 2</span> and <span class="texhtml"><i>r</i><sub>0</sub> = 147</span>
</td></tr>
<tr>
<td>1</td>
<td><span class="texhtml">462 = <i>q</i><sub>1</sub> 147 + <i>r</i><sub>1</sub></span></td>
<td><span class="texhtml"><i>q</i><sub>1</sub> = 3</span> and <span class="texhtml"><i>r</i><sub>1</sub> = 21</span>
</td></tr>
<tr>
<td>2</td>
<td><span class="texhtml">147 = <i>q</i><sub>2</sub> 21 + <i>r</i><sub>2</sub></span></td>
<td><span class="texhtml"><i>q</i><sub>2</sub> = 7</span> and <span class="texhtml"><i>r</i><sub>2</sub> = 0</span>; algorithm ends
</td></tr></tbody></table>
<div class="mw-heading mw-heading3"><h3 id="Visualization">Visualization</h3></div>
<p>The Euclidean algorithm can be visualized in terms of the tiling analogy given above for the greatest common divisor.<sup id="cite_ref-Kimberling_1983_20-0" class="reference"><a href="#cite_note-Kimberling_1983-20"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup> Assume that we wish to cover an <span class="texhtml"><i>a</i>×<i>b</i></span> rectangle with square tiles exactly, where <span class="texhtml"><i>a</i></span> is the larger of the two numbers. We first attempt to tile the rectangle using <span class="texhtml"><i>b</i>×<i>b</i></span> square tiles; however, this leaves an <span class="texhtml"><i>r</i><sub>0</sub>×<i>b</i></span> residual rectangle untiled, where <span class="texhtml"><i>r</i><sub>0</sub> &lt; <i>b</i></span>. We then attempt to tile the residual rectangle with <span class="texhtml"><i>r</i><sub>0</sub>×<i>r</i><sub>0</sub></span> square tiles. This leaves a second residual rectangle <span class="texhtml"><i>r</i><sub>1</sub>×<i>r</i><sub>0</sub></span>, which we attempt to tile using <span class="texhtml"><i>r</i><sub>1</sub>×<i>r</i><sub>1</sub></span> square tiles, and so on. The sequence ends when there is no residual rectangle, i.e., when the square tiles cover the previous residual rectangle exactly. The length of the sides of the smallest square tile is the GCD of the dimensions of the original rectangle. For example, the smallest square tile in the adjacent figure is <span class="texhtml">21×21</span> (shown in red), and <span class="texhtml">21</span> is the GCD of <span class="texhtml">1071</span> and <span class="texhtml">462</span>, the dimensions of the original rectangle (shown in green).
</p>
<div class="mw-heading mw-heading3"><h3 id="Euclidean_division">Euclidean division</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Euclidean_division" title="Euclidean division">Euclidean division</a></div>
<p>At every step <span class="texhtml"><i>k</i></span>, the Euclidean algorithm computes a quotient <span class="texhtml"><i>q</i><sub><i>k</i></sub></span> and remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> from two numbers <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span> and <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span>
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> = <i>q</i><sub><i>k</i></sub> <i>r</i><sub><i>k</i>−1</sub> + <i>r</i><sub><i>k</i></sub></span>,</dd></dl>
<p>where the <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> is non-negative and is strictly less than the <a href="Absolute_value" title="Absolute value">absolute value</a> of <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span>. The theorem which underlies the definition of the <a href="Euclidean_division" title="Euclidean division">Euclidean division</a> ensures that such a quotient and remainder always exist and are unique.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p><p>In Euclid's original version of the algorithm, the quotient and remainder are found by repeated subtraction; that is, <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span> is subtracted from <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span> repeatedly until the remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> is smaller than <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span>. After that <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> and <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span> are exchanged and the process is iterated. Euclidean division reduces all the steps between two exchanges into a single step, which is thus more efficient. Moreover, the quotients are not needed, thus one may replace Euclidean division by the <a href="Modulo_operation" class="mw-redirect" title="Modulo operation">modulo operation</a>, which gives only the remainder. Thus the iteration of the Euclidean algorithm becomes simply
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i></sub> = <i>r</i><sub><i>k</i>−2</sub> mod <i>r</i><sub><i>k</i>−1</sub></span>.</dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Implementations">Implementations</h3></div>
<p>Implementations of the algorithm may be expressed in <a href="Pseudocode" title="Pseudocode">pseudocode</a>. For example, the division-based version may be <a href="Computer_programming" title="Computer programming">programmed</a> as<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup>
</p>
<pre><b>function</b> gcd(a, b)
<b>while</b> b ≠ 0
t&nbsp;:= b
b&nbsp;:= a <b>mod</b> b
a&nbsp;:= t
<b>return</b> a
</pre>
<p>At the beginning of the <span class="texhtml"><i>k</i></span>th iteration, the variable <span class="texhtml"><i>b</i></span> holds the latest remainder <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span>, whereas the variable <span class="texhtml"><i>a</i></span> holds its predecessor, <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span>. The step <span class="texhtml"><i>b</i>&nbsp;:= <i>a</i> mod <i>b</i></span> is equivalent to the above recursion formula <span class="texhtml"><i>r</i><sub><i>k</i></sub> ≡ <i>r</i><sub><i>k</i>−2</sub> mod <i>r</i><sub><i>k</i>−1</sub></span>. The <a href="Temporary_variable" title="Temporary variable">temporary variable</a> <span class="texhtml"><i>t</i></span> holds the value of <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span> while the next remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> is being calculated. At the end of the loop iteration, the variable <span class="texhtml"><i>b</i></span> holds the remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span>, whereas the variable <span class="texhtml"><i>a</i></span> holds its predecessor, <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span>.
</p><p>(If negative inputs are allowed, or if the <code><b>mod</b></code> function may return negative values, the last line must be replaced with <span class="nowrap"><code><b>return abs</b>(a)</code></span>.)
</p><p>In the subtraction-based version, which was Euclid's original version, the remainder calculation (<span class="nowrap"><code>b&nbsp;:= a <b>mod</b> b</code></span>) is replaced by repeated subtraction.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> Contrary to the division-based version, which works with arbitrary integers as input, the subtraction-based version supposes that the input consists of positive integers and stops when <span class="texhtml"><i>a</i> = <i>b</i></span>:
</p>
<pre><b>function</b> gcd(a, b)
<b>while</b> a ≠ b
<b>if</b> a &gt; b
a&nbsp;:= a − b
<b>else</b>
b&nbsp;:= b − a
<b>return</b> a
</pre>
<p>The variables <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> alternate holding the previous remainders <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span> and <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span>. Assume that <span class="texhtml"><i>a</i></span> is larger than <span class="texhtml"><i>b</i></span> at the beginning of an iteration; then <span class="texhtml"><i>a</i></span> equals <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span>, since <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> &gt; <i>r</i><sub><i>k</i>−1</sub></span>. During the loop iteration, <span class="texhtml"><i>a</i></span> is reduced by multiples of the previous remainder <span class="texhtml"><i>b</i></span> until <span class="texhtml"><i>a</i></span> is smaller than <span class="texhtml"><i>b</i></span>. Then <span class="texhtml"><i>a</i></span> is the next remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span>. Then <span class="texhtml"><i>b</i></span> is reduced by multiples of <span class="texhtml"><i>a</i></span> until it is again smaller than <span class="texhtml"><i>a</i></span>, giving the next remainder <span class="texhtml"><i>r</i><sub><i>k</i>+1</sub></span>, and so on.
</p><p>The recursive version<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup> is based on the equality of the GCDs of successive remainders and the stopping condition <span class="texhtml">gcd(<i>r</i><sub><i>N</i>−1</sub>, 0) = <i>r</i><sub><i>N</i>−1</sub></span>.
</p>
<pre><b>function</b> gcd(a, b)
<b>if</b> b = 0
<b>return</b> a
<b>else</b>
<b>return</b> gcd(b, a <b>mod</b> b)
</pre>
<p>(As above, if negative inputs are allowed, or if the <code><b>mod</b></code> function may return negative values, the instruction <span class="nowrap"><code><b>return</b> a</code></span> must be replaced by <span class="nowrap"><code><b>return max</b>(a, −a)</code></span>.)
</p><p>For illustration, the <span class="texhtml">gcd(1071, 462)</span> is calculated from the equivalent <span class="texhtml">gcd(462, 1071 mod 462) = gcd(462, 147)</span>. The latter GCD is calculated from the <span class="texhtml">gcd(147, 462 mod 147) = gcd(147, 21)</span>, which in turn is calculated from the <span class="texhtml">gcd(21, 147 mod 21) = gcd(21, 0) = 21</span>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Method_of_least_absolute_remainders">Method of least absolute remainders</h3></div>
<p>In another version of Euclid's algorithm, the quotient at each step is increased by one if the resulting negative remainder is smaller in magnitude than the typical positive remainder.<sup id="cite_ref-Ore_least_abs_remainders_25-0" class="reference"><a href="#cite_note-Ore_least_abs_remainders-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Stewart_1964_26-0" class="reference"><a href="#cite_note-Stewart_1964-26"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> Previously, the equation
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> = <i>q</i><sub><i>k</i></sub> <i>r</i><sub><i>k</i>−1</sub> + <i>r</i><sub><i>k</i></sub></span></dd></dl>
<p>assumed that <span class="texhtml">|<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i>−1</sub></span>| &gt; <i>r</i><sub><i>k</i></sub> &gt; 0</span>. However, an alternative negative remainder <span class="texhtml"><i>e</i><sub><i>k</i></sub></span> can be computed:
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> = (<i>q</i><sub><i>k</i></sub> + 1) <i>r</i><sub><i>k</i>−1</sub> + <i>e</i><sub><i>k</i></sub></span></dd></dl>
<p>if <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub>&nbsp;&gt;&nbsp;0</span> or
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> = (<i>q</i><sub><i>k</i></sub> – 1) <i>r</i><sub><i>k</i>−1</sub> + <i>e</i><sub><i>k</i></sub></span></dd></dl>
<p>if <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub>&nbsp;&lt;&nbsp;0</span>.
</p><p>If <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> is replaced by <span class="texhtml"><i>e</i><sub><i>k</i></sub></span>. when <span class="texhtml">|<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>e</i><sub><i>k</i></sub></span>| &lt; |<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i></sub></span>|</span>, then one gets a variant of Euclidean algorithm such that
</p>
<dl><dd><span class="texhtml">|<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i></sub></span>| ≤ |<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i>−1</sub></span>| / 2</span></dd></dl>
<p>at each step.
</p><p><a href="Leopold_Kronecker" title="Leopold Kronecker">Leopold Kronecker</a> has shown that this version requires the fewest steps of any version of Euclid's algorithm.<sup id="cite_ref-Ore_least_abs_remainders_25-1" class="reference"><a href="#cite_note-Ore_least_abs_remainders-25"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Stewart_1964_26-1" class="reference"><a href="#cite_note-Stewart_1964-26"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> More generally, it has been proven that, for every input numbers <i>a</i> and <i>b</i>, the number of steps is minimal if and only if <span class="texhtml"><i>q</i><sub><i>k</i></sub></span> is chosen in order that <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \left|{\frac {r_{k+1}}{r_{k}}}\right|<{\frac {1}{\varphi }}\sim 0.618,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow>
<mo>|</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mfrac>
</mrow>
<mo>|</mo>
</mrow>
<mo>&lt;</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>φ<!-- φ --></mi>
</mfrac>
</mrow>
<mo>∼<!-- ∼ --></mo>
<mn>0.618</mn>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \left|{\frac {r_{k+1}}{r_{k}}}\right|&lt;{\frac {1}{\varphi }}\sim 0.618,}</annotation>
</semantics>
</math></span><img src="./284616d6eabd3159aa6f2fbbb9800dae0b079bd1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.338ex; width:20.864ex; height:5.676ex;" alt="{\displaystyle \left|{\frac {r_{k+1}}{r_{k}}}\right|<{\frac {1}{\varphi }}\sim 0.618,}" loading="lazy"></span> where <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \varphi }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>φ<!-- φ --></mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \varphi }</annotation>
</semantics>
</math></span><img src="./33ee699558d09cf9d653f6351f9fda0b2f4aaa3e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:1.52ex; height:2.176ex;" alt="{\displaystyle \varphi }" loading="lazy"></span> is the <a href="Golden_ratio" title="Golden ratio">golden ratio</a>.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Historical_development">Historical development</h2></div>

<p>The Euclidean algorithm is one of the oldest algorithms in common use.<sup id="cite_ref-Knuth,_p._318_28-0" class="reference"><a href="#cite_note-Knuth,_p._318-28"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup> It appears in <a href="Euclid's_Elements" title="Euclid's Elements">Euclid's <i>Elements</i></a> (c.&nbsp;300&nbsp;BC), specifically in Book&nbsp;7 (Propositions 1–2) and Book&nbsp;10 (Propositions 2–3). In Book&nbsp;7, the algorithm is formulated for integers, whereas in Book&nbsp;10, it is formulated for lengths of line segments. (In modern usage, one would say it was formulated there for <a href="Real_number" title="Real number">real numbers</a>. But lengths, areas, and volumes, represented as real numbers in modern usage, are not measured in the same units and there is no natural unit of length, area, or volume; the concept of real numbers was unknown at that time.) The latter algorithm is geometrical. The GCD of two lengths <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> corresponds to the greatest length <span class="texhtml"><i>g</i></span> that measures <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> evenly; in other words, the lengths <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> are both integer multiples of the length <span class="texhtml"><i>g</i></span>.
</p><p>The algorithm was probably not discovered by <a href="Euclid" title="Euclid">Euclid</a>, who compiled results from earlier mathematicians in his <i>Elements</i>.<sup id="cite_ref-Weil_1983_29-0" class="reference"><a href="#cite_note-Weil_1983-29"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Jones_1994_30-0" class="reference"><a href="#cite_note-Jones_1994-30"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup> The mathematician and historian <a href="Bartel_Leendert_van_der_Waerden" title="Bartel Leendert van der Waerden">B. L. van der Waerden</a> suggests that Book VII derives from a textbook on <a href="Number_theory" title="Number theory">number theory</a> written by mathematicians in the school of <a href="Pythagoras" title="Pythagoras">Pythagoras</a>.<sup id="cite_ref-van_der_Waerden_1954_31-0" class="reference"><a href="#cite_note-van_der_Waerden_1954-31"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup> The algorithm was probably known by <a href="Eudoxus_of_Cnidus" title="Eudoxus of Cnidus">Eudoxus of Cnidus</a> (about 375 BC).<sup id="cite_ref-Knuth,_p._318_28-1" class="reference"><a href="#cite_note-Knuth,_p._318-28"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup> The algorithm may even pre-date Eudoxus,<sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-34" class="reference"><a href="#cite_note-34"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup> judging from the use of the technical term ἀνθυφαίρεσις (<i>anthyphairesis</i>, reciprocal subtraction) in works by Euclid and <a href="Aristotle" title="Aristotle">Aristotle</a>.<sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup> Claude Brezinski, following remarks by <a href="Pappus_of_Alexandria" title="Pappus of Alexandria">Pappus of Alexandria</a>, credits the algorithm to <a href="Theaetetus_(mathematician)" title="Theaetetus (mathematician)">Theaetetus</a> (c. 417 – c. 369 BC).<sup id="cite_ref-36" class="reference"><a href="#cite_note-36"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup>
</p><p>Centuries later, Euclid's algorithm was discovered independently both in India and in China,<sup id="cite_ref-Stillwell,_p._31_37-0" class="reference"><a href="#cite_note-Stillwell,_p._31-37"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup> primarily to solve <a href="Diophantine_equation" title="Diophantine equation">Diophantine equations</a> that arose in astronomy and making accurate calendars. In the late 5th century, the Indian mathematician and astronomer <a href="Aryabhata" title="Aryabhata">Aryabhata</a> described the algorithm as the "pulverizer",<sup id="cite_ref-Tattersall,_p._70_38-0" class="reference"><a href="#cite_note-Tattersall,_p._70-38"><span class="cite-bracket">[</span>37<span class="cite-bracket">]</span></a></sup> perhaps because of its effectiveness in solving Diophantine equations.<sup id="cite_ref-39" class="reference"><a href="#cite_note-39"><span class="cite-bracket">[</span>38<span class="cite-bracket">]</span></a></sup> Although a special case of the <a href="Chinese_remainder_theorem" title="Chinese remainder theorem">Chinese remainder theorem</a> had already been described in the Chinese book <i><a href="Sunzi_Suanjing" title="Sunzi Suanjing">Sunzi Suanjing</a></i>,<sup id="cite_ref-40" class="reference"><a href="#cite_note-40"><span class="cite-bracket">[</span>39<span class="cite-bracket">]</span></a></sup> the general solution was published by <a href="Qin_Jiushao" title="Qin Jiushao">Qin Jiushao</a> in his 1247 book <i>Shushu Jiuzhang</i> (數書九章 <i><a href="Mathematical_Treatise_in_Nine_Sections" title="Mathematical Treatise in Nine Sections">Mathematical Treatise in Nine Sections</a></i>).<sup id="cite_ref-41" class="reference"><a href="#cite_note-41"><span class="cite-bracket">[</span>40<span class="cite-bracket">]</span></a></sup> The Euclidean algorithm was first described <i>numerically</i> and popularized in Europe in the second edition of <a href="Claude_Gaspard_Bachet_de_M%C3%A9ziriac" class="mw-redirect" title="Claude Gaspard Bachet de Méziriac">Bachet's</a> <i>Problèmes plaisants et délectables</i> (<i>Pleasant and enjoyable problems</i>, 1624).<sup id="cite_ref-Tattersall,_p._70_38-1" class="reference"><a href="#cite_note-Tattersall,_p._70-38"><span class="cite-bracket">[</span>37<span class="cite-bracket">]</span></a></sup> In Europe, it was likewise used to solve Diophantine equations and in developing <a href="Simple_continued_fraction" title="Simple continued fraction">continued fractions</a>. The <a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">extended Euclidean algorithm</a> was published by the English mathematician <a href="Nicholas_Saunderson" title="Nicholas Saunderson">Nicholas Saunderson</a>,<sup id="cite_ref-42" class="reference"><a href="#cite_note-42"><span class="cite-bracket">[</span>41<span class="cite-bracket">]</span></a></sup> who attributed it to <a href="Roger_Cotes" title="Roger Cotes">Roger Cotes</a> as a method for computing continued fractions efficiently.<sup id="cite_ref-43" class="reference"><a href="#cite_note-43"><span class="cite-bracket">[</span>42<span class="cite-bracket">]</span></a></sup>
</p><p>In the 19th century, the Euclidean algorithm led to the development of new number systems, such as <a href="Gaussian_integer" title="Gaussian integer">Gaussian integers</a> and <a href="Eisenstein_integer" title="Eisenstein integer">Eisenstein integers</a>. In 1815, <a href="Carl_Friedrich_Gauss" title="Carl Friedrich Gauss">Carl Gauss</a> used the Euclidean algorithm to demonstrate unique factorization of <a href="Gaussian_integer" title="Gaussian integer">Gaussian integers</a>, although his work was first published in 1832.<sup id="cite_ref-Gauss_1832_44-0" class="reference"><a href="#cite_note-Gauss_1832-44"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup> Gauss mentioned the algorithm in his <i><a href="Disquisitiones_Arithmeticae" title="Disquisitiones Arithmeticae">Disquisitiones Arithmeticae</a></i> (published 1801), but only as a method for <a href="Continued_fraction" title="Continued fraction">continued fractions</a>.<sup id="cite_ref-Stillwell,_p._31_37-1" class="reference"><a href="#cite_note-Stillwell,_p._31-37"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup> <a href="Peter_Gustav_Lejeune_Dirichlet" title="Peter Gustav Lejeune Dirichlet">Peter Gustav Lejeune Dirichlet</a> seems to have been the first to describe the Euclidean algorithm as the basis for much of number theory.<sup id="cite_ref-45" class="reference"><a href="#cite_note-45"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup> Lejeune Dirichlet noted that many results of number theory, such as unique factorization, would hold true for any other system of numbers to which the Euclidean algorithm could be applied.<sup id="cite_ref-46" class="reference"><a href="#cite_note-46"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup> Lejeune Dirichlet's lectures on number theory were edited and extended by <a href="Richard_Dedekind" title="Richard Dedekind">Richard Dedekind</a>, who used Euclid's algorithm to study <a href="Algebraic_integer" title="Algebraic integer">algebraic integers</a>, a new general type of number. For example, Dedekind was the first to prove <a href="Fermat's_theorem_on_sums_of_two_squares" title="Fermat's theorem on sums of two squares">Fermat's two-square theorem</a> using the unique factorization of Gaussian integers.<sup id="cite_ref-47" class="reference"><a href="#cite_note-47"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup> Dedekind also defined the concept of a <a href="Euclidean_domain" title="Euclidean domain">Euclidean domain</a>, a number system in which a generalized version of the Euclidean algorithm can be defined (as described <a href="#Euclidean_domains">below</a>). In the closing decades of the 19th century, the Euclidean algorithm gradually became eclipsed by Dedekind's more general theory of <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideals</a>.<sup id="cite_ref-48" class="reference"><a href="#cite_note-48"><span class="cite-bracket">[</span>47<span class="cite-bracket">]</span></a></sup>
</p>
<table class="toccolours" style="float: left; margin-left: 1em; margin-right: 1em; font-size: 85%; color:black; width:23em; max-width: 25%;" cellspacing="5">
<tbody><tr>
<td style="text-align: left;">
<p>"[The Euclidean algorithm] is the granddaddy of all algorithms, because it is the oldest nontrivial algorithm that has survived to the present day."
</p>
</td></tr>
<tr>
<td style="text-align: left;"><a href="Donald_Knuth" title="Donald Knuth">Donald Knuth</a>, <i>The Art of Computer Programming, Vol. 2: Seminumerical Algorithms</i>, 2nd edition (1981), p.&nbsp;318.
</td></tr></tbody></table>
<p>Other applications of Euclid's algorithm were developed in the 19th century. In 1829, <a href="Jacques_Charles_Fran%C3%A7ois_Sturm" title="Jacques Charles François Sturm">Charles Sturm</a> showed that the algorithm was useful in the <a href="Sturm's_theorem" title="Sturm's theorem">Sturm chain</a> method for counting the real roots of polynomials in any given interval.<sup id="cite_ref-49" class="reference"><a href="#cite_note-49"><span class="cite-bracket">[</span>48<span class="cite-bracket">]</span></a></sup>
</p><p>The Euclidean algorithm was the first <a href="Integer_relation_algorithm" title="Integer relation algorithm">integer relation algorithm</a>, which is a method for finding integer relations between commensurate real numbers. Several novel <a href="Integer_relation_algorithm" title="Integer relation algorithm">integer relation algorithms</a> have been developed, such as the algorithm of <a href="Helaman_Ferguson" title="Helaman Ferguson">Helaman Ferguson</a> and R.W. Forcade (1979)<sup id="cite_ref-50" class="reference"><a href="#cite_note-50"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup> and the <a href="Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz_lattice_basis_reduction_algorithm" title="Lenstra–Lenstra–Lovász lattice basis reduction algorithm">LLL algorithm</a>.<sup id="cite_ref-51" class="reference"><a href="#cite_note-51"><span class="cite-bracket">[</span>50<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-52" class="reference"><a href="#cite_note-52"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup>
</p><p>In 1969, Cole and Davie developed a two-player game based on the Euclidean algorithm, called <i>The Game of Euclid</i>,<sup id="cite_ref-53" class="reference"><a href="#cite_note-53"><span class="cite-bracket">[</span>52<span class="cite-bracket">]</span></a></sup> which has an optimal strategy.<sup id="cite_ref-54" class="reference"><a href="#cite_note-54"><span class="cite-bracket">[</span>53<span class="cite-bracket">]</span></a></sup> The players begin with two piles of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> stones. The players take turns removing <span class="texhtml"><i>m</i></span> multiples of the smaller pile from the larger. Thus, if the two piles consist of <span class="texhtml"><i>x</i></span> and <span class="texhtml"><i>y</i></span> stones, where <span class="texhtml"><i>x</i></span> is larger than <span class="texhtml"><i>y</i></span>, the next player can reduce the larger pile from <span class="texhtml"><i>x</i></span> stones to <span class="texhtml"><i>x</i> − <i>my</i></span> stones, as long as the latter is a nonnegative integer. The winner is the first player to reduce one pile to zero stones.<sup id="cite_ref-55" class="reference"><a href="#cite_note-55"><span class="cite-bracket">[</span>54<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-56" class="reference"><a href="#cite_note-56"><span class="cite-bracket">[</span>55<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Mathematical_applications">Mathematical applications</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Bézout's_identity">Bézout's identity</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="B%C3%A9zout's_identity" title="Bézout's identity">Bézout's identity</a></div>
<p>Bézout's identity states that the greatest common divisor <span class="texhtml"><i>g</i></span> of two integers <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> can be represented as a linear sum of the original two numbers <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>.<sup id="cite_ref-57" class="reference"><a href="#cite_note-57"><span class="cite-bracket">[</span>56<span class="cite-bracket">]</span></a></sup> In other words, it is always possible to find integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> such that <span class="texhtml"><i>g</i> = <i>sa</i> + <i>tb</i></span>.<sup id="cite_ref-58" class="reference"><a href="#cite_note-58"><span class="cite-bracket">[</span>57<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-59" class="reference"><a href="#cite_note-59"><span class="cite-bracket">[</span>58<span class="cite-bracket">]</span></a></sup>
</p><p>The integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> can be calculated from the quotients <span class="texhtml"><i>q</i><sub>0</sub></span>, <span class="texhtml"><i>q</i><sub>1</sub></span>, etc. by reversing the order of equations in Euclid's algorithm.<sup id="cite_ref-60" class="reference"><a href="#cite_note-60"><span class="cite-bracket">[</span>59<span class="cite-bracket">]</span></a></sup> Beginning with the next-to-last equation, <span class="texhtml"><i>g</i></span> can be expressed in terms of the quotient <span class="texhtml"><i>q</i><sub><i>N</i>−1</sub></span> and the two preceding remainders, <span class="texhtml"><i>r</i><sub><i>N</i>−2</sub></span> and <span class="texhtml"><i>r</i><sub><i>N</i>−3</sub></span>:
</p>
<dl><dd><span class="texhtml"><i>g</i> = <i>r</i><sub><i>N</i>−1</sub> = <i>r</i><sub><i>N</i>−3</sub> − <i>q</i><sub><i>N</i>−1</sub> <i>r</i><sub><i>N</i>−2</sub></span>.</dd></dl>
<p>Those two remainders can be likewise expressed in terms of their quotients and preceding remainders,
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>N</i>−2</sub> = <i>r</i><sub><i>N</i>−4</sub> − <i>q</i><sub><i>N</i>−2</sub> <i>r</i><sub><i>N</i>−3</sub></span> and</dd>
<dd><span class="texhtml"><i>r</i><sub><i>N</i>−3</sub> = <i>r</i><sub><i>N</i>−5</sub> − <i>q</i><sub><i>N</i>−3</sub> <i>r</i><sub><i>N</i>−4</sub></span>.</dd></dl>
<p>Substituting these formulae for <span class="texhtml"><i>r</i><sub><i>N</i>−2</sub></span> and <span class="texhtml"><i>r</i><sub><i>N</i>−3</sub></span> into the first equation yields <span class="texhtml"><i>g</i></span> as a linear sum of the remainders <span class="texhtml"><i>r</i><sub><i>N</i>−4</sub></span> and <span class="texhtml"><i>r</i><sub><i>N</i>−5</sub></span>. The process of substituting remainders by formulae involving their predecessors can be continued until the original numbers <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> are reached:
</p>
<dl><dd><span class="texhtml"><i>r</i><sub>2</sub> = <i>r</i><sub>0</sub> − <i>q</i><sub>2</sub> <i>r</i><sub>1</sub></span></dd>
<dd><span class="texhtml"><i>r</i><sub>1</sub> = <i>b</i> − <i>q</i><sub>1</sub> <i>r</i><sub>0</sub></span></dd>
<dd><span class="texhtml"><i>r</i><sub>0</sub> = <i>a</i> − <i>q</i><sub>0</sub> <i>b</i></span>.</dd></dl>
<p>After all the remainders <span class="texhtml"><i>r</i><sub>0</sub></span>, <span class="texhtml"><i>r</i><sub>1</sub></span>, etc. have been substituted, the final equation expresses <span class="texhtml"><i>g</i></span> as a linear sum of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>, so that <span class="texhtml"><i>g</i> = <i>sa</i> + <i>tb</i></span>.
</p><p>The Euclidean algorithm, and thus Bézout's identity, can be generalized to the context of <a href="Euclidean_domain" title="Euclidean domain">Euclidean domains</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Principal_ideals_and_related_problems">Principal ideals and related problems</h3></div>
<p>Bézout's identity provides yet another definition of the greatest common divisor <span class="texhtml"><i>g</i></span> of two numbers <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>.<sup id="cite_ref-Leveque_p33_13-1" class="reference"><a href="#cite_note-Leveque_p33-13"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> Consider the set of all numbers <span class="texhtml"><i>ua</i> + <i>vb</i></span>, where <span class="texhtml"><i>u</i></span> and <span class="texhtml"><i>v</i></span> are any two integers. Since <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span> are both divisible by <span class="texhtml"><i>g</i></span>, every number in the set is divisible by <span class="texhtml"><i>g</i></span>. In other words, every number of the set is an integer multiple of <span class="texhtml"><i>g</i></span>. This is true for every common divisor of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>. However, unlike other common divisors, the greatest common divisor is a member of the set; by Bézout's identity, choosing <span class="texhtml"><i>u</i> = <i>s</i></span> and <span class="texhtml"><i>v</i> = <i>t</i></span> gives <span class="texhtml"><i>g</i></span>. A smaller common divisor cannot be a member of the set, since every member of the set must be divisible by <span class="texhtml"><i>g</i></span>. Conversely, any multiple <span class="texhtml"><i>m</i></span> of <span class="texhtml"><i>g</i></span> can be obtained by choosing <span class="texhtml"><i>u</i> = <i>ms</i></span> and <span class="texhtml"><i>v</i> = <i>mt</i></span>, where <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> are the integers of Bézout's identity. This may be seen by multiplying Bézout's identity by <i>m</i>,
</p>
<dl><dd><span class="texhtml"><i>mg</i> = <i>msa</i> + <i>mtb</i></span>.</dd></dl>
<p>Therefore, the set of all numbers <span class="texhtml"><i>ua</i> + <i>vb</i></span> is equivalent to the set of multiples <span class="texhtml"><i>m</i></span> of <span class="texhtml"><i>g</i></span>. In other words, the set of all possible sums of integer multiples of two numbers (<span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>) is equivalent to the set of multiples of <span class="texhtml">gcd(<i>a</i>, <i>b</i>)</span>. The GCD is said to be the generator of the <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideal</a> of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>. This GCD definition led to the modern <a href="Abstract_algebra" title="Abstract algebra">abstract algebraic</a> concepts of a <a href="Principal_ideal" title="Principal ideal">principal ideal</a> (an ideal generated by a single element) and a <a href="Principal_ideal_domain" title="Principal ideal domain">principal ideal domain</a> (a <a href="Domain_(ring_theory)" title="Domain (ring theory)">domain</a> in which every ideal is a principal ideal).
</p><p>Certain problems can be solved using this result.<sup id="cite_ref-61" class="reference"><a href="#cite_note-61"><span class="cite-bracket">[</span>60<span class="cite-bracket">]</span></a></sup> For example, consider two measuring cups of volume <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>. By adding/subtracting <span class="texhtml"><i>u</i></span> multiples of the first cup and <span class="texhtml"><i>v</i></span> multiples of the second cup, any volume <span class="texhtml"><i>ua</i> + <i>vb</i></span> can be measured out. These volumes are all multiples of <span class="texhtml"><i>g</i> = gcd(<i>a</i>, <i>b</i>)</span>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Extended_Euclidean_algorithm">Extended Euclidean algorithm</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">Extended Euclidean algorithm</a></div>
<p>The integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> of Bézout's identity can be computed efficiently using the <a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">extended Euclidean algorithm</a>. This extension adds two recursive equations to Euclid's algorithm<sup id="cite_ref-62" class="reference"><a href="#cite_note-62"><span class="cite-bracket">[</span>61<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="texhtml"><i>s</i><sub><i>k</i></sub> = <i>s</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub><i>s</i><sub><i>k</i>−1</sub></span></dd>
<dd><span class="texhtml"><i>t</i><sub><i>k</i></sub> = <i>t</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub><i>t</i><sub><i>k</i>−1</sub></span></dd></dl>
<p>with the starting values
</p>
<dl><dd><span class="texhtml"><i>s</i><sub>−2</sub> = 1, <i>t</i><sub>−2</sub> = 0</span></dd>
<dd><span class="texhtml"><i>s</i><sub>−1</sub> = 0, <i>t</i><sub>−1</sub> = 1</span>.</dd></dl>
<p>Using this recursion, Bézout's integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> are given by <span class="texhtml"><i>s</i> = <i>s</i><sub><i>N</i></sub></span> and <span class="texhtml"><i>t</i> = <i>t</i><sub><i>N</i></sub></span>, where <span class="texhtml"><i>N</i> + 1</span> is the step on which the algorithm terminates with <span class="texhtml"><i>r</i><sub><i>N</i>+1</sub> = 0</span>.
</p><p>The validity of this approach can be shown by induction. Assume that the recursion formula is correct up to step <span class="texhtml"><i>k</i> − 1</span> of the algorithm; in other words, assume that
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>j</i></sub> = <i>s</i><sub><i>j</i></sub> <i>a</i> + <i>t</i><sub><i>j</i></sub> <i>b</i></span></dd></dl>
<p>for all <span class="texhtml"><i>j</i></span> less than <span class="texhtml"><i>k</i></span>. The <span class="texhtml"><i>k</i></span>th step of the algorithm gives the equation
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i></sub> = <i>r</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub><i>r</i><sub><i>k</i>−1</sub></span>.</dd></dl>
<p>Since the recursion formula has been assumed to be correct for <span class="texhtml"><i>r</i><sub><i>k</i>−2</sub></span> and <span class="texhtml"><i>r</i><sub><i>k</i>−1</sub></span>, they may be expressed in terms of the corresponding <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> variables
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i></sub> = (<i>s</i><sub><i>k</i>−2</sub> <i>a</i> + <i>t</i><sub><i>k</i>−2</sub> <i>b</i>) − <i>q</i><sub><i>k</i></sub>(<i>s</i><sub><i>k</i>−1</sub> <i>a</i> + <i>t</i><sub><i>k</i>−1</sub> <i>b</i>)</span>.</dd></dl>
<p>Rearranging this equation yields the recursion formula for step <span class="texhtml"><i>k</i></span>, as required
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i></sub> = <i>s</i><sub><i>k</i></sub> <i>a</i> + <i>t</i><sub><i>k</i></sub> <i>b</i> = (<i>s</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub><i>s</i><sub><i>k</i>−1</sub>) <i>a</i> + (<i>t</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub><i>t</i><sub><i>k</i>−1</sub>) <i>b</i></span>.</dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Matrix_method">Matrix method</h3></div>
<p>The integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> can also be found using an equivalent <a href="Matrix_(mathematics)" title="Matrix (mathematics)">matrix</a> method.<sup id="cite_ref-Koshy_2002_63-0" class="reference"><a href="#cite_note-Koshy_2002-63"><span class="cite-bracket">[</span>62<span class="cite-bracket">]</span></a></sup> The sequence of equations of Euclid's algorithm
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}a&amp;=q_{0}b+r_{0}\\b&amp;=q_{1}r_{0}+r_{1}\\&amp;\,\,\,\vdots \\r_{N-2}&amp;=q_{N}r_{N-1}+0\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd>
<mi>a</mi>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mi>b</mi>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd></mtd>
<mtd>
<mi></mi>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mo>⋮<!-- ⋮ --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}a&amp;=q_{0}b+r_{0}\\b&amp;=q_{1}r_{0}+r_{1}\\&amp;\,\,\,\vdots \\r_{N-2}&amp;=q_{N}r_{N-1}+0\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./bb95dceee016c6715d26238fc6adfb8eec615c97.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -6.005ex; width:20.263ex; height:13.176ex;" alt="{\displaystyle {\begin{aligned}a&amp;=q_{0}b+r_{0}\\b&amp;=q_{1}r_{0}+r_{1}\\&amp;\,\,\,\vdots \\r_{N-2}&amp;=q_{N}r_{N-1}+0\end{aligned}}}" loading="lazy"></span></dd></dl>
<p>can be written as a product of <span class="texhtml">2×2</span> quotient matrices multiplying a two-dimensional remainder vector
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}b\\r_{0}\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{0}\\r_{1}\end{pmatrix}}=\cdots =\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>a</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>b</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>=</mo>
<munderover>
<mo>∏<!-- ∏ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>=</mo>
<mn>0</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</munderover>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}b\\r_{0}\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{0}\\r_{1}\end{pmatrix}}=\cdots =\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}\,.}</annotation>
</semantics>
</math></span><img src="./257eaf53f86665ef4e927000e9c285441ac40841.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:85.216ex; height:7.343ex;" alt="{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}b\\r_{0}\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{0}\\r_{1}\end{pmatrix}}=\cdots =\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}\,.}" loading="lazy"></span></dd></dl>
<p>Let <span class="texhtml"><b>M</b></span> represent the product of all the quotient matrices
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbf {M} ={\begin{pmatrix}m_{11}&amp;m_{12}\\m_{21}&amp;m_{22}\end{pmatrix}}=\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}\cdots {\begin{pmatrix}q_{N}&amp;1\\1&amp;0\end{pmatrix}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="bold">M</mi>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>11</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>12</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>21</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>22</mn>
</mrow>
</msub>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<munderover>
<mo>∏<!-- ∏ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>=</mo>
<mn>0</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</munderover>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>⋯<!-- ⋯ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathbf {M} ={\begin{pmatrix}m_{11}&amp;m_{12}\\m_{21}&amp;m_{22}\end{pmatrix}}=\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}\cdots {\begin{pmatrix}q_{N}&amp;1\\1&amp;0\end{pmatrix}}\,.}</annotation>
</semantics>
</math></span><img src="./3825723fc0b1e3723a637c7f51507b73ba36cc17.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:73.428ex; height:7.343ex;" alt="{\displaystyle \mathbf {M} ={\begin{pmatrix}m_{11}&amp;m_{12}\\m_{21}&amp;m_{22}\end{pmatrix}}=\prod _{i=0}^{N}{\begin{pmatrix}q_{i}&amp;1\\1&amp;0\end{pmatrix}}={\begin{pmatrix}q_{0}&amp;1\\1&amp;0\end{pmatrix}}{\begin{pmatrix}q_{1}&amp;1\\1&amp;0\end{pmatrix}}\cdots {\begin{pmatrix}q_{N}&amp;1\\1&amp;0\end{pmatrix}}\,.}" loading="lazy"></span></dd></dl>
<p>This simplifies the Euclidean algorithm to the form
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}g\\0\end{pmatrix}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>a</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="bold">M</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="bold">M</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>g</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}g\\0\end{pmatrix}}\,.}</annotation>
</semantics>
</math></span><img src="./7c5287400df82c95499e1c507d932d07c147c08d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:32.057ex; height:6.176ex;" alt="{\displaystyle {\begin{pmatrix}a\\b\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}r_{N-1}\\0\end{pmatrix}}=\mathbf {M} {\begin{pmatrix}g\\0\end{pmatrix}}\,.}" loading="lazy"></span></dd></dl>
<p>To express <span class="texhtml"><i>g</i></span> as a linear sum of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>, both sides of this equation can be multiplied by the <a href="Invertible_matrix" title="Invertible matrix">inverse</a> of the matrix <span class="texhtml"><b>M</b></span>.<sup id="cite_ref-Koshy_2002_63-1" class="reference"><a href="#cite_note-Koshy_2002-63"><span class="cite-bracket">[</span>62<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Bach_1996_64-0" class="reference"><a href="#cite_note-Bach_1996-64"><span class="cite-bracket">[</span>63<span class="cite-bracket">]</span></a></sup> The <a href="Determinant" title="Determinant">determinant</a> of <span class="texhtml"><b>M</b></span> equals <span class="texhtml">(−1)<sup><i>N</i>+1</sup></span>, since it equals the product of the determinants of the quotient matrices, each of which is negative one. Since the determinant of <span class="texhtml"><b>M</b></span> is never zero, the vector of the final remainders can be solved using the inverse of <span class="texhtml"><b>M</b></span>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{pmatrix}g\\0\end{pmatrix}}=\mathbf {M} ^{-1}{\begin{pmatrix}a\\b\end{pmatrix}}=(-1)^{N+1}{\begin{pmatrix}m_{22}&amp;-m_{12}\\-m_{21}&amp;m_{11}\end{pmatrix}}{\begin{pmatrix}a\\b\end{pmatrix}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>g</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="bold">M</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>a</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mo>=</mo>
<mo stretchy="false">(</mo>
<mo>−<!-- − --></mo>
<mn>1</mn>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>+</mo>
<mn>1</mn>
</mrow>
</msup>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>22</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mo>−<!-- − --></mo>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>12</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<mo>−<!-- − --></mo>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>21</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>11</mn>
</mrow>
</msub>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>(</mo>
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mi>a</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
</mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{pmatrix}g\\0\end{pmatrix}}=\mathbf {M} ^{-1}{\begin{pmatrix}a\\b\end{pmatrix}}=(-1)^{N+1}{\begin{pmatrix}m_{22}&amp;-m_{12}\\-m_{21}&amp;m_{11}\end{pmatrix}}{\begin{pmatrix}a\\b\end{pmatrix}}\,.}</annotation>
</semantics>
</math></span><img src="./e9daccd9cfbe875345f40d5ce6c4807c8a463668.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:54.758ex; height:6.176ex;" alt="{\displaystyle {\begin{pmatrix}g\\0\end{pmatrix}}=\mathbf {M} ^{-1}{\begin{pmatrix}a\\b\end{pmatrix}}=(-1)^{N+1}{\begin{pmatrix}m_{22}&amp;-m_{12}\\-m_{21}&amp;m_{11}\end{pmatrix}}{\begin{pmatrix}a\\b\end{pmatrix}}\,.}" loading="lazy"></span></dd></dl>
<p>Since the top equation gives
</p>
<dl><dd><span class="texhtml"><i>g</i> = (−1)<sup><i>N</i>+1</sup> ( <i>m</i><sub>22</sub> <i>a</i> − <i>m</i><sub>12</sub> <i>b</i>)</span>,</dd></dl>
<p>the two integers of Bézout's identity are <span class="texhtml"><i>s</i> = (−1)<sup><i>N</i>+1</sup><i>m</i><sub>22</sub></span> and <span class="texhtml"><i>t</i> = (−1)<sup><i>N</i></sup><i>m</i><sub>12</sub></span>. The matrix method is as efficient as the equivalent recursion, with two multiplications and two additions per step of the Euclidean algorithm.
</p>
<div class="mw-heading mw-heading3"><h3 id="Euclid's_lemma_and_unique_factorization">Euclid's lemma and unique factorization</h3></div>
<p>Bézout's identity is essential to many applications of Euclid's algorithm, such as demonstrating the <a href="Fundamental_theorem_of_arithmetic" title="Fundamental theorem of arithmetic">unique factorization</a> of numbers into prime factors.<sup id="cite_ref-65" class="reference"><a href="#cite_note-65"><span class="cite-bracket">[</span>64<span class="cite-bracket">]</span></a></sup> To illustrate this, suppose that a number <span class="texhtml"><i>L</i></span> can be written as a product of two factors <span class="texhtml"><i>u</i></span> and <span class="texhtml"><i>v</i></span>, that is, <span class="texhtml"><i>L</i> = <i>uv</i></span>. If another number <span class="texhtml"><i>w</i></span> also divides <span class="texhtml"><i>L</i></span> but is coprime with <span class="texhtml"><i>u</i></span>, then <span class="texhtml"><i>w</i></span> must divide <span class="texhtml"><i>v</i></span>, by the following argument: If the greatest common divisor of <span class="texhtml"><i>u</i></span> and <span class="texhtml"><i>w</i></span> is <span class="texhtml">1</span>, then integers <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> can be found such that
</p>
<dl><dd><span class="texhtml">1 = <i>su</i> + <i>tw</i></span></dd></dl>
<p>by Bézout's identity. Multiplying both sides by <span class="texhtml"><i>v</i></span> gives the relation:
</p>
<dl><dd><span class="texhtml"><i>v</i> = <i>suv</i> + <i>twv</i> = <i>sL</i> + <i>twv</i></span></dd></dl>
<p>Since <span class="texhtml"><i>w</i></span> divides both terms on the right-hand side, it must also divide the left-hand side, <span class="texhtml"><i>v</i></span>. This result is known as <a href="Euclid's_lemma" title="Euclid's lemma">Euclid's lemma</a>.<sup id="cite_ref-Ore,_p._44_66-0" class="reference"><a href="#cite_note-Ore,_p._44-66"><span class="cite-bracket">[</span>65<span class="cite-bracket">]</span></a></sup> Specifically, if a prime number divides <span class="texhtml"><i>L</i></span>, then it must divide at least one factor of <span class="texhtml"><i>L</i></span>. Conversely, if a number <span class="texhtml"><i>w</i></span> is coprime to each of a series of numbers <span class="texhtml"><i>a</i><sub>1</sub></span>, <span class="texhtml"><i>a</i><sub>2</sub></span>, ..., <span class="texhtml"><i>a</i><sub><i>n</i></sub></span>, then <span class="texhtml"><i>w</i></span> is also coprime to their product, <span class="texhtml"><i>a</i><sub>1</sub> × <i>a</i><sub>2</sub> × ... × <i>a</i><sub><i>n</i></sub></span>.<sup id="cite_ref-Ore,_p._44_66-1" class="reference"><a href="#cite_note-Ore,_p._44-66"><span class="cite-bracket">[</span>65<span class="cite-bracket">]</span></a></sup>
</p><p>Euclid's lemma suffices to prove that every number has a unique factorization into prime numbers.<sup id="cite_ref-67" class="reference"><a href="#cite_note-67"><span class="cite-bracket">[</span>66<span class="cite-bracket">]</span></a></sup> To see this, assume the contrary, that there are two independent factorizations of <span class="texhtml"><i>L</i></span> into <span class="texhtml"><i>m</i></span> and <span class="texhtml"><i>n</i></span> prime factors, respectively
</p>
<dl><dd><span class="texhtml"><i>L</i> = <i>p</i><sub>1</sub><i>p</i><sub>2</sub>...<i>p</i><sub><i>m</i></sub> = <i>q</i><sub>1</sub><i>q</i><sub>2</sub>...<i>q</i><sub><i>n</i></sub>&nbsp;</span>.</dd></dl>
<p>Since each prime <span class="texhtml"><i>p</i></span> divides <span class="texhtml"><i>L</i></span> by assumption, it must also divide one of the <span class="texhtml"><i>q</i></span> factors; since each <span class="texhtml"><i>q</i></span> is prime as well, it must be that <span class="texhtml"><i>p</i> = <i>q</i></span>. Iteratively dividing by the <span class="texhtml"><i>p</i></span> factors shows that each <span class="texhtml"><i>p</i></span> has an equal counterpart <span class="texhtml"><i>q</i></span>; the two prime factorizations are identical except for their order. The unique factorization of numbers into primes has many applications in mathematical proofs, as shown below.
</p>
<div class="mw-heading mw-heading3"><h3 id="Linear_Diophantine_equations">Linear Diophantine equations</h3></div>

<p><a href="Diophantine_equation" title="Diophantine equation">Diophantine equations</a> are equations in which the solutions are restricted to integers; they are named after the 3rd-century Alexandrian mathematician <a href="Diophantus" title="Diophantus">Diophantus</a>.<sup id="cite_ref-68" class="reference"><a href="#cite_note-68"><span class="cite-bracket">[</span>67<span class="cite-bracket">]</span></a></sup> A typical <i>linear</i> Diophantine equation seeks integers <span class="texhtml"><i>x</i></span> and <span class="texhtml"><i>y</i></span> such that<sup id="cite_ref-69" class="reference"><a href="#cite_note-69"><span class="cite-bracket">[</span>68<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="texhtml"><i>ax</i> + <i>by</i> = <i>c</i></span></dd></dl>
<p>where <span class="texhtml"><i>a</i></span>, <span class="texhtml"><i>b</i></span> and <span class="texhtml"><i>c</i></span> are given integers. This can be written as an equation for <span class="texhtml"><i>x</i></span> in <a href="Modular_arithmetic" title="Modular arithmetic">modular arithmetic</a>:
</p>
<dl><dd><span class="texhtml"><i>ax</i> ≡ <i>c</i> mod <i>b</i></span>.</dd></dl>
<p>Let <span class="texhtml"><i>g</i></span> be the greatest common divisor of <span class="texhtml"><i>a</i></span> and <span class="texhtml"><i>b</i></span>. Both terms in <span class="texhtml"><i>ax</i> + <i>by</i></span> are divisible by <span class="texhtml"><i>g</i></span>; therefore, <span class="texhtml"><i>c</i></span> must also be divisible by <span class="texhtml"><i>g</i></span>, or the equation has no solutions. By dividing both sides by <span class="texhtml"><i>c</i>/<i>g</i></span>, the equation can be reduced to Bezout's identity
</p>
<dl><dd><span class="texhtml"><i>sa</i> + <i>tb</i> = <i>g</i></span>,</dd></dl>
<p>where <span class="texhtml"><i>s</i></span> and <span class="texhtml"><i>t</i></span> can be found by the <a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">extended Euclidean algorithm</a>.<sup id="cite_ref-70" class="reference"><a href="#cite_note-70"><span class="cite-bracket">[</span>69<span class="cite-bracket">]</span></a></sup> This provides one solution to the Diophantine equation, <span class="texhtml"><i>x</i><sub>1</sub> = <i>s</i> (<i>c</i>/<i>g</i>)</span> and <span class="texhtml"><i>y</i><sub>1</sub> = <i>t</i> (<i>c</i>/<i>g</i>)</span>.
</p><p>In general, a linear Diophantine equation has no solutions, or an infinite number of solutions.<sup id="cite_ref-71" class="reference"><a href="#cite_note-71"><span class="cite-bracket">[</span>70<span class="cite-bracket">]</span></a></sup> To find the latter, consider two solutions, <span class="texhtml">(<i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>)</span> and <span class="texhtml">(<i>x</i><sub>2</sub>, <i>y</i><sub>2</sub>)</span>, where
</p>
<dl><dd><span class="texhtml"><i>ax</i><sub>1</sub> + <i>by</i><sub>1</sub> = <i>c</i> = <i>ax</i><sub>2</sub> + <i>by</i><sub>2</sub></span></dd></dl>
<p>or equivalently
</p>
<dl><dd><span class="texhtml"><i>a</i>(<i>x</i><sub>1</sub> − <i>x</i><sub>2</sub>) = <i>b</i>(<i>y</i><sub>2</sub> − <i>y</i><sub>1</sub>)</span>.</dd></dl>
<p>Therefore, the smallest difference between two <span class="texhtml"><i>x</i></span> solutions is <span class="texhtml"><i>b</i>/<i>g</i></span>, whereas the smallest difference between two <span class="texhtml"><i>y</i></span> solutions is <span class="texhtml"><i>a</i>/<i>g</i></span>. Thus, the solutions may be expressed as
</p>
<dl><dd><span class="texhtml"><i>x</i> = <i>x</i><sub>1</sub> − <i>bu</i>/<i>g</i></span></dd>
<dd><span class="texhtml"><i>y</i> = <i>y</i><sub>1</sub> + <i>au</i>/<i>g</i></span>.</dd></dl>
<p>By allowing <span class="texhtml"><i>u</i></span> to vary over all possible integers, an infinite family of solutions can be generated from a single solution <span class="texhtml">(<i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>)</span>. If the solutions are required to be <i>positive</i> integers <span class="texhtml">(<i>x</i> &gt; 0, <i>y</i> &gt; 0)</span>, only a finite number of solutions may be possible. This restriction on the acceptable solutions allows some systems of Diophantine equations with more unknowns than equations to have a finite number of solutions;<sup id="cite_ref-72" class="reference"><a href="#cite_note-72"><span class="cite-bracket">[</span>71<span class="cite-bracket">]</span></a></sup> this is impossible for a <a href="System_of_linear_equations" title="System of linear equations">system of linear equations</a> when the solutions can be any <a href="Real_number" title="Real number">real number</a> (see <a href="Underdetermined_system" title="Underdetermined system">Underdetermined system</a>).
</p>
<div class="mw-heading mw-heading3"><h3 id="Multiplicative_inverses_and_the_RSA_algorithm">Multiplicative inverses and the RSA algorithm</h3></div>
<p>A <a href="Finite_field" title="Finite field">finite field</a> is a set of numbers with four generalized operations. The operations are called addition, subtraction, multiplication and division and have their usual properties, such as <a href="Commutativity" class="mw-redirect" title="Commutativity">commutativity</a>, <a href="Associativity" class="mw-redirect" title="Associativity">associativity</a> and <a href="Distributivity" class="mw-redirect" title="Distributivity">distributivity</a>. An example of a finite field is the set of 13 numbers <span class="texhtml">{0,&nbsp;1,&nbsp;2,&nbsp;...,&nbsp;12}</span> using <a href="Modular_arithmetic" title="Modular arithmetic">modular arithmetic</a>. In this field, the results of any mathematical operation (addition, subtraction, multiplication, or division) is reduced <a href="Modulo_operation" class="mw-redirect" title="Modulo operation">modulo</a> <span class="texhtml">13</span>; that is, multiples of <span class="texhtml">13</span> are added or subtracted until the result is brought within the range <span class="texhtml">0</span>–<span class="texhtml">12</span>. For example, the result of <span class="texhtml">5 × 7 = 35 mod 13 = 9</span>. Such finite fields can be defined for any prime <span class="texhtml"><i>p</i></span>; using more sophisticated definitions, they can also be defined for any power <span class="texhtml"><i>m</i></span> of a prime <span class="texhtml"><i>p</i><sup><i>m</i></sup></span>. Finite fields are often called <a href="%C3%89variste_Galois" title="Évariste Galois">Galois</a> fields, and are abbreviated as <span class="texhtml">GF(<i>p</i>)</span> or <span class="texhtml">GF(<i>p</i><sup><i>m</i></sup></span>).
</p><p>In such a field with <span class="texhtml"><i>m</i></span> numbers, every nonzero element <span class="texhtml"><i>a</i></span> has a unique <a href="Modular_multiplicative_inverse" title="Modular multiplicative inverse">modular multiplicative inverse</a>, <span class="texhtml"><i>a</i><sup>−1</sup></span> such that <span class="texhtml"><i>aa</i><sup>−1</sup> = <i>a</i><sup>−1</sup><i>a</i> ≡ 1 mod <i>m</i></span>. This inverse can be found by solving the congruence equation <span class="texhtml"><i>ax</i> ≡ 1 mod <i>m</i></span>,<sup id="cite_ref-73" class="reference"><a href="#cite_note-73"><span class="cite-bracket">[</span>72<span class="cite-bracket">]</span></a></sup> or the equivalent linear Diophantine equation<sup id="cite_ref-74" class="reference"><a href="#cite_note-74"><span class="cite-bracket">[</span>73<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="texhtml"><i>ax</i> + <i>my</i> = 1</span>.</dd></dl>
<p>This equation can be solved by the Euclidean algorithm, as described <a href="#Linear_Diophantine_equations">above</a>. Finding multiplicative inverses is an essential step in the <a href="RSA_algorithm" class="mw-redirect" title="RSA algorithm">RSA algorithm</a>, which is widely used in <a href="Electronic_commerce" class="mw-redirect" title="Electronic commerce">electronic commerce</a>; specifically, the equation determines the integer used to decrypt the message.<sup id="cite_ref-75" class="reference"><a href="#cite_note-75"><span class="cite-bracket">[</span>74<span class="cite-bracket">]</span></a></sup> Although the RSA algorithm uses <a href="Ring_(mathematics)" title="Ring (mathematics)">rings</a> rather than fields, the Euclidean algorithm can still be used to find a multiplicative inverse where one exists. The Euclidean algorithm also has other applications in <a href="Error-correcting_code" class="mw-redirect" title="Error-correcting code">error-correcting codes</a>; for example, it can be used as an alternative to the <a href="Berlekamp%E2%80%93Massey_algorithm" title="Berlekamp–Massey algorithm">Berlekamp–Massey algorithm</a> for decoding <a href="BCH_code" title="BCH code">BCH</a> and <a href="Reed%E2%80%93Solomon_code" class="mw-redirect" title="Reed–Solomon code">Reed–Solomon codes</a>, which are based on Galois fields.<sup id="cite_ref-76" class="reference"><a href="#cite_note-76"><span class="cite-bracket">[</span>75<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Chinese_remainder_theorem">Chinese remainder theorem</h3></div>
<p>Euclid's algorithm can also be used to solve multiple linear Diophantine equations.<sup id="cite_ref-77" class="reference"><a href="#cite_note-77"><span class="cite-bracket">[</span>76<span class="cite-bracket">]</span></a></sup> Such equations arise in the <a href="Chinese_remainder_theorem" title="Chinese remainder theorem">Chinese remainder theorem</a>, which describes a novel method to represent an integer <i>x</i>. Instead of representing an integer by its digits, it may be represented by its remainders <i>x</i><sub><i>i</i></sub> modulo a set of <i>N</i> coprime numbers <i>m</i><sub><i>i</i></sub>:<sup id="cite_ref-78" class="reference"><a href="#cite_note-78"><span class="cite-bracket">[</span>77<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}x_{1}&amp;\equiv x{\pmod {m_{1}}}\\x_{2}&amp;\equiv x{\pmod {m_{2}}}\\&amp;\,\,\,\vdots \\x_{N}&amp;\equiv x{\pmod {m_{N}}}\,.\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>≡<!-- ≡ --></mo>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mspace width="1em"></mspace>
<mo stretchy="false">(</mo>
<mi>mod</mi>
<mspace width="0.333em"></mspace>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>≡<!-- ≡ --></mo>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mspace width="1em"></mspace>
<mo stretchy="false">(</mo>
<mi>mod</mi>
<mspace width="0.333em"></mspace>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd></mtd>
<mtd>
<mi></mi>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mo>⋮<!-- ⋮ --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>≡<!-- ≡ --></mo>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mspace width="1em"></mspace>
<mo stretchy="false">(</mo>
<mi>mod</mi>
<mspace width="0.333em"></mspace>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<mo stretchy="false">)</mo>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}x_{1}&amp;\equiv x{\pmod {m_{1}}}\\x_{2}&amp;\equiv x{\pmod {m_{2}}}\\&amp;\,\,\,\vdots \\x_{N}&amp;\equiv x{\pmod {m_{N}}}\,.\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./31b5396502c5c41d731d975448aa9db9805d503f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -6.171ex; width:22.651ex; height:13.509ex;" alt="{\displaystyle {\begin{aligned}x_{1}&amp;\equiv x{\pmod {m_{1}}}\\x_{2}&amp;\equiv x{\pmod {m_{2}}}\\&amp;\,\,\,\vdots \\x_{N}&amp;\equiv x{\pmod {m_{N}}}\,.\end{aligned}}}" loading="lazy"></span></dd></dl>
<p>The goal is to determine <i>x</i> from its <i>N</i> remainders <i>x</i><sub><i>i</i></sub>. The solution is to combine the multiple equations into a single linear Diophantine equation with a much larger modulus <i>M</i> that is the product of all the individual moduli <i>m</i><sub><i>i</i></sub>, and define <i>M</i><sub><i>i</i></sub> as
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{i}={\frac {M}{m_{i}}}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>M</mi>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
</mfrac>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{i}={\frac {M}{m_{i}}}.}</annotation>
</semantics>
</math></span><img src="./1f3b49175a6f76039f5f0af2949b0685dc124285.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.171ex; width:10.475ex; height:5.509ex;" alt="{\displaystyle M_{i}={\frac {M}{m_{i}}}.}" loading="lazy"></span></dd></dl>
<p>Thus, each <i>M</i><sub><i>i</i></sub> is the product of all the moduli <i>except</i> <i>m</i><sub><i>i</i></sub>. The solution depends on finding <i>N</i> new numbers <i>h</i><sub><i>i</i></sub> such that
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{i}h_{i}\equiv 1{\pmod {m_{i}}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>≡<!-- ≡ --></mo>
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mspace width="1em"></mspace>
<mo stretchy="false">(</mo>
<mi>mod</mi>
<mspace width="0.333em"></mspace>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo stretchy="false">)</mo>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle M_{i}h_{i}\equiv 1{\pmod {m_{i}}}\,.}</annotation>
</semantics>
</math></span><img src="./ed2433873b4e6d1c11fc1d5a42d3e0f1720a2e0f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:23.011ex; height:2.843ex;" alt="{\displaystyle M_{i}h_{i}\equiv 1{\pmod {m_{i}}}\,.}" loading="lazy"></span></dd></dl>
<p>With these numbers <i>h</i><sub><i>i</i></sub>, any integer <i>x</i> can be reconstructed from its remainders <i>x</i><sub><i>i</i></sub> by the equation
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x\equiv (x_{1}M_{1}h_{1}+x_{2}M_{2}h_{2}+\cdots +x_{N}M_{N}h_{N}){\pmod {M}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>x</mi>
<mo>≡<!-- ≡ --></mo>
<mo stretchy="false">(</mo>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>+</mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>+</mo>
<msub>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<msub>
<mi>M</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mspace width="1em"></mspace>
<mo stretchy="false">(</mo>
<mi>mod</mi>
<mspace width="0.333em"></mspace>
<mi>M</mi>
<mo stretchy="false">)</mo>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle x\equiv (x_{1}M_{1}h_{1}+x_{2}M_{2}h_{2}+\cdots +x_{N}M_{N}h_{N}){\pmod {M}}\,.}</annotation>
</semantics>
</math></span><img src="./8fed369909ea8053d7168a70800c32bcc5e21b24.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:56.81ex; height:2.843ex;" alt="{\displaystyle x\equiv (x_{1}M_{1}h_{1}+x_{2}M_{2}h_{2}+\cdots +x_{N}M_{N}h_{N}){\pmod {M}}\,.}" loading="lazy"></span></dd></dl>
<p>Since these numbers <i>h</i><sub><i>i</i></sub> are the multiplicative inverses of the <i>M</i><sub><i>i</i></sub>, they may be found using Euclid's algorithm as described in the previous subsection.
</p>
<div class="mw-heading mw-heading3"><h3 id="Stern–Brocot_tree">Stern–Brocot tree</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Stern%E2%80%93Brocot_tree" title="Stern–Brocot tree">Stern–Brocot tree</a></div>
<p>The Euclidean algorithm can be used to arrange the set of all positive <a href="Rational_number" title="Rational number">rational numbers</a> into an infinite <a href="Binary_search_tree" title="Binary search tree">binary search tree</a>, called the <a href="Stern%E2%80%93Brocot_tree" title="Stern–Brocot tree">Stern–Brocot tree</a>.
The number 1 (expressed as a fraction 1/1) is placed at the root of the tree, and the location of any other number <i>a</i>/<i>b</i> can be found by computing gcd(<i>a</i>,<i>b</i>) using the original form of the Euclidean algorithm, in which each step replaces the larger of the two given numbers by its difference with the smaller number (not its remainder), stopping when two equal numbers are reached. A step of the Euclidean algorithm that replaces the first of the two numbers corresponds to a step in the tree from a node to its right child, and a step that replaces the second of the two numbers corresponds to a step in the tree from a node to its left child. The sequence of steps constructed in this way does not depend on whether <i>a</i>/<i>b</i> is given in lowest terms, and forms a path from the root to a node containing the number <i>a</i>/<i>b</i>.<sup id="cite_ref-79" class="reference"><a href="#cite_note-79"><span class="cite-bracket">[</span>78<span class="cite-bracket">]</span></a></sup> This fact can be used to prove that each positive rational number appears exactly once in this tree.
</p><p>For example, 3/4 can be found by starting at the root, going to the left once, then to the right twice:
</p>

<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}&amp;\gcd(3,4)&amp;\leftarrow \\={}&amp;\gcd(3,1)&amp;\rightarrow \\={}&amp;\gcd(2,1)&amp;\rightarrow \\={}&amp;\gcd(1,1).\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd></mtd>
<mtd>
<mi></mi>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mn>3</mn>
<mo>,</mo>
<mn>4</mn>
<mo stretchy="false">)</mo>
</mtd>
<mtd>
<mo stretchy="false">←<!-- ← --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">

</mrow>
</mtd>
<mtd>
<mi></mi>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mn>3</mn>
<mo>,</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mtd>
<mtd>
<mo stretchy="false">→<!-- → --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">

</mrow>
</mtd>
<mtd>
<mi></mi>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mn>2</mn>
<mo>,</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mtd>
<mtd>
<mo stretchy="false">→<!-- → --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">

</mrow>
</mtd>
<mtd>
<mi></mi>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mn>1</mn>
<mo>,</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}&amp;\gcd(3,4)&amp;\leftarrow \\={}&amp;\gcd(3,1)&amp;\rightarrow \\={}&amp;\gcd(2,1)&amp;\rightarrow \\={}&amp;\gcd(1,1).\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./3d0bf20425d35b1e9a42b85e40630f5c1263661f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -5.671ex; width:19.863ex; height:12.509ex;" alt="{\displaystyle {\begin{aligned}&amp;\gcd(3,4)&amp;\leftarrow \\={}&amp;\gcd(3,1)&amp;\rightarrow \\={}&amp;\gcd(2,1)&amp;\rightarrow \\={}&amp;\gcd(1,1).\end{aligned}}}" loading="lazy"></span></dd></dl>
<p>The Euclidean algorithm has almost the same relationship to another binary tree on the rational numbers called the <a href="Calkin%E2%80%93Wilf_tree" title="Calkin–Wilf tree">Calkin–Wilf tree</a>. The difference is that the path is reversed: instead of producing a path from the root of the tree to a target, it produces a path from the target to the root.
</p>
<div class="mw-heading mw-heading3"><h3 id="Continued_fractions">Continued fractions</h3></div>
<p>The Euclidean algorithm has a close relationship with <a href="Continued_fraction" title="Continued fraction">continued fractions</a>.<sup id="cite_ref-Vinogradov_1954_80-0" class="reference"><a href="#cite_note-Vinogradov_1954-80"><span class="cite-bracket">[</span>79<span class="cite-bracket">]</span></a></sup> The sequence of equations can be written in the form
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}{\frac {a}{b}}&amp;=q_{0}+{\frac {r_{0}}{b}}\\{\frac {b}{r_{0}}}&amp;=q_{1}+{\frac {r_{1}}{r_{0}}}\\{\frac {r_{0}}{r_{1}}}&amp;=q_{2}+{\frac {r_{2}}{r_{1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{k-2}}{r_{k-1}}}&amp;=q_{k}+{\frac {r_{k}}{r_{k-1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{N-2}}{r_{N-1}}}&amp;=q_{N}\,.\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mi>b</mi>
</mfrac>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>b</mi>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd></mtd>
<mtd>
<mi></mi>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mo>⋮<!-- ⋮ --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd></mtd>
<mtd>
<mi></mi>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mspace width="thinmathspace"></mspace>
<mo>⋮<!-- ⋮ --></mo>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mfrac>
</mrow>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}{\frac {a}{b}}&amp;=q_{0}+{\frac {r_{0}}{b}}\\{\frac {b}{r_{0}}}&amp;=q_{1}+{\frac {r_{1}}{r_{0}}}\\{\frac {r_{0}}{r_{1}}}&amp;=q_{2}+{\frac {r_{2}}{r_{1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{k-2}}{r_{k-1}}}&amp;=q_{k}+{\frac {r_{k}}{r_{k-1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{N-2}}{r_{N-1}}}&amp;=q_{N}\,.\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./b55cba911954b8e8434bd23c6e56826a4f935e29.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -17.005ex; width:19.567ex; height:35.176ex;" alt="{\displaystyle {\begin{aligned}{\frac {a}{b}}&amp;=q_{0}+{\frac {r_{0}}{b}}\\{\frac {b}{r_{0}}}&amp;=q_{1}+{\frac {r_{1}}{r_{0}}}\\{\frac {r_{0}}{r_{1}}}&amp;=q_{2}+{\frac {r_{2}}{r_{1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{k-2}}{r_{k-1}}}&amp;=q_{k}+{\frac {r_{k}}{r_{k-1}}}\\&amp;\,\,\,\vdots \\{\frac {r_{N-2}}{r_{N-1}}}&amp;=q_{N}\,.\end{aligned}}}" loading="lazy"></span></dd></dl>
<p>The last term on the right-hand side always equals the inverse of the left-hand side of the next equation. Thus, the first two equations may be combined to form
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {r_{1}}{r_{0}}}}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {r_{1}}{r_{0}}}}}\,.}</annotation>
</semantics>
</math></span><img src="./0ec09639bf1927ae58b0e48225fafb08b46bec3d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -6.671ex; width:19.837ex; height:10.843ex;" alt="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {r_{1}}{r_{0}}}}}\,.}" loading="lazy"></span></dd></dl>
<p>The third equation may be used to substitute the denominator term <i>r</i><sub>1</sub>/<i>r</i><sub>0</sub>, yielding
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {r_{2}}{r_{1}}}}}}}\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {r_{2}}{r_{1}}}}}}}\,.}</annotation>
</semantics>
</math></span><img src="./fc9747d183fabc6a43a44b7dbc81df348d595e26.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -10.171ex; width:25.605ex; height:14.343ex;" alt="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {r_{2}}{r_{1}}}}}}}\,.}" loading="lazy"></span></dd></dl>
<p>The final ratio of remainders <i>r</i><sub><i>k</i></sub>/<i>r</i><sub><i>k</i>−1</sub> can always be replaced using the next equation in the series, up to the final equation. The result is a continued fraction
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {1}{\ddots +{\cfrac {1}{q_{N}}}}}}}}}=[q_{0};q_{1},q_{2},\ldots ,q_{N}]\,.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo>⋱<!-- ⋱ --></mo>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
<mo>=</mo>
<mo stretchy="false">[</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>;</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msub>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>N</mi>
</mrow>
</msub>
<mo stretchy="false">]</mo>
<mspace width="thinmathspace"></mspace>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {1}{\ddots +{\cfrac {1}{q_{N}}}}}}}}}=[q_{0};q_{1},q_{2},\ldots ,q_{N}]\,.}</annotation>
</semantics>
</math></span><img src="./bfd6202ce1dc46510c7894abba456c3b899c58bf.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -13.838ex; width:53.526ex; height:18.009ex;" alt="{\displaystyle {\frac {a}{b}}=q_{0}+{\cfrac {1}{q_{1}+{\cfrac {1}{q_{2}+{\cfrac {1}{\ddots +{\cfrac {1}{q_{N}}}}}}}}}=[q_{0};q_{1},q_{2},\ldots ,q_{N}]\,.}" loading="lazy"></span></dd></dl>
<p>In the worked example <a href="#Worked_example">above</a>, the gcd(1071, 462) was calculated, and the quotients <i>q</i><sub><i>k</i></sub> were 2, 3 and 7, respectively. Therefore, the fraction 1071/462 may be written
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\frac {1071}{462}}=2+{\cfrac {1}{3+{\cfrac {1}{7}}}}=[2;3,7]}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1071</mn>
<mn>462</mn>
</mfrac>
</mrow>
<mo>=</mo>
<mn>2</mn>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</mstyle>
</mrow>
<mrow>
<mpadded width="0" height="8.6pt" depth="3pt">
<mrow></mrow>
</mpadded>
<mstyle displaystyle="false" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mn>7</mn>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
</mrow>
</mstyle>
</mrow>
</mfrac>
</mrow>
<mo>=</mo>
<mo stretchy="false">[</mo>
<mn>2</mn>
<mo>;</mo>
<mn>3</mn>
<mo>,</mo>
<mn>7</mn>
<mo stretchy="false">]</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\frac {1071}{462}}=2+{\cfrac {1}{3+{\cfrac {1}{7}}}}=[2;3,7]}</annotation>
</semantics>
</math></span><img src="./41bb1b741861a853bc9f7bcbcd91315b07ffdac0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -6.671ex; width:29.372ex; height:10.843ex;" alt="{\displaystyle {\frac {1071}{462}}=2+{\cfrac {1}{3+{\cfrac {1}{7}}}}=[2;3,7]}" loading="lazy"></span></dd></dl>
<p>as can be confirmed by calculation.
</p>
<div class="mw-heading mw-heading3"><h3 id="Factorization_algorithms">Factorization algorithms</h3></div>
<p>Calculating a greatest common divisor is an essential step in several <a href="Integer_factorization" title="Integer factorization">integer factorization</a> algorithms,<sup id="cite_ref-81" class="reference"><a href="#cite_note-81"><span class="cite-bracket">[</span>80<span class="cite-bracket">]</span></a></sup> such as <a href="Pollard's_rho_algorithm" title="Pollard's rho algorithm">Pollard's rho algorithm</a>,<sup id="cite_ref-82" class="reference"><a href="#cite_note-82"><span class="cite-bracket">[</span>81<span class="cite-bracket">]</span></a></sup> <a href="Shor's_algorithm" title="Shor's algorithm">Shor's algorithm</a>,<sup id="cite_ref-83" class="reference"><a href="#cite_note-83"><span class="cite-bracket">[</span>82<span class="cite-bracket">]</span></a></sup> <a href="Dixon's_factorization_method" title="Dixon's factorization method">Dixon's factorization method</a><sup id="cite_ref-84" class="reference"><a href="#cite_note-84"><span class="cite-bracket">[</span>83<span class="cite-bracket">]</span></a></sup> and the <a href="Lenstra_elliptic_curve_factorization" class="mw-redirect" title="Lenstra elliptic curve factorization">Lenstra elliptic curve factorization</a>.<sup id="cite_ref-85" class="reference"><a href="#cite_note-85"><span class="cite-bracket">[</span>84<span class="cite-bracket">]</span></a></sup> The Euclidean algorithm may be used to find this GCD efficiently. <a href="Continued_fraction_factorization" title="Continued fraction factorization">Continued fraction factorization</a> uses continued fractions, which are determined using Euclid's algorithm.<sup id="cite_ref-86" class="reference"><a href="#cite_note-86"><span class="cite-bracket">[</span>85<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Algorithmic_efficiency">Algorithmic efficiency</h2></div>

<p>The computational efficiency of Euclid's algorithm has been studied thoroughly.<sup id="cite_ref-87" class="reference"><a href="#cite_note-87"><span class="cite-bracket">[</span>86<span class="cite-bracket">]</span></a></sup> This efficiency can be described by the number of division steps the algorithm requires, multiplied by the computational expense of each step. The first known analysis of Euclid's algorithm is due to <a href="Antoine_Andr%C3%A9_Louis_Reynaud" title="Antoine André Louis Reynaud">A. A. L. Reynaud</a> in 1811,<sup id="cite_ref-88" class="reference"><a href="#cite_note-88"><span class="cite-bracket">[</span>87<span class="cite-bracket">]</span></a></sup> who showed that the number of division steps on input (<i>u</i>, <i>v</i>) is bounded by <i>v</i>; later he improved this to <i>v</i>/2&nbsp;+&nbsp;2. Later, in 1841, <a href="Pierre_Joseph_%C3%89tienne_Finck" title="Pierre Joseph Étienne Finck">P. J. E. Finck</a> showed<sup id="cite_ref-89" class="reference"><a href="#cite_note-89"><span class="cite-bracket">[</span>88<span class="cite-bracket">]</span></a></sup> that the number of division steps is at most 2&nbsp;log<sub>2</sub>&nbsp;<i>v</i>&nbsp;+&nbsp;1, and hence Euclid's algorithm runs in time polynomial in the size of the input.<sup id="cite_ref-FOOTNOTEShallit1994_90-0" class="reference"><a href="#cite_note-FOOTNOTEShallit1994-90"><span class="cite-bracket">[</span>89<span class="cite-bracket">]</span></a></sup> <a href="%C3%89mile_L%C3%A9ger" title="Émile Léger">Émile Léger</a>, in 1837, studied the worst case, which is when the inputs are consecutive <a href="Fibonacci_numbers" class="mw-redirect" title="Fibonacci numbers">Fibonacci numbers</a>.<sup id="cite_ref-FOOTNOTEShallit1994_90-1" class="reference"><a href="#cite_note-FOOTNOTEShallit1994-90"><span class="cite-bracket">[</span>89<span class="cite-bracket">]</span></a></sup> Finck's analysis was refined by <a href="Gabriel_Lam%C3%A9" title="Gabriel Lamé">Gabriel Lamé</a> in 1844,<sup id="cite_ref-91" class="reference"><a href="#cite_note-91"><span class="cite-bracket">[</span>90<span class="cite-bracket">]</span></a></sup> who showed that the number of steps required for completion is never more than five times the number <i>h</i> of base-10 digits of the smaller number&nbsp;<i>b</i>.<sup id="cite_ref-92" class="reference"><a href="#cite_note-92"><span class="cite-bracket">[</span>91<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-93" class="reference"><a href="#cite_note-93"><span class="cite-bracket">[</span>92<span class="cite-bracket">]</span></a></sup>
</p><p>In the <a href="Uniform_cost_model" class="mw-redirect" title="Uniform cost model">uniform cost model</a> (suitable for analyzing the complexity of gcd calculation on numbers that fit into a single machine word), each step of the algorithm takes <a href="Constant_time" class="mw-redirect" title="Constant time">constant time</a>, and Lamé's analysis implies that the total running time is also <i>O</i>(<i>h</i>). However, in a model of computation suitable for computation with larger numbers, the computational expense of a single remainder computation in the algorithm can be as large as <i>O</i>(<i>h</i><sup>2</sup>).<sup id="cite_ref-Knuth-257-261_94-0" class="reference"><a href="#cite_note-Knuth-257-261-94"><span class="cite-bracket">[</span>93<span class="cite-bracket">]</span></a></sup> In this case the total time for all of the steps of the algorithm can be analyzed using a <a href="Telescoping_series" title="Telescoping series">telescoping series</a>, showing that it is also <i>O</i>(<i>h</i><sup>2</sup>). Modern algorithmic techniques based on the <a href="Sch%C3%B6nhage%E2%80%93Strassen_algorithm" title="Schönhage–Strassen algorithm">Schönhage–Strassen algorithm</a> for fast integer multiplication can be used to speed this up, leading to <a href="Quasilinear_time" class="mw-redirect" title="Quasilinear time">quasilinear algorithms</a> for the GCD.<sup id="cite_ref-Crandall_2001_95-0" class="reference"><a href="#cite_note-Crandall_2001-95"><span class="cite-bracket">[</span>94<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Moller08_96-0" class="reference"><a href="#cite_note-Moller08-96"><span class="cite-bracket">[</span>95<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Number_of_steps">Number of steps</h3></div>
<p>The number of steps to calculate the GCD of two natural numbers, <i>a</i> and <i>b</i>, may be denoted by <i>T</i>(<i>a</i>,&nbsp;<i>b</i>).<sup id="cite_ref-Knuth,_p._344_97-0" class="reference"><a href="#cite_note-Knuth,_p._344-97"><span class="cite-bracket">[</span>96<span class="cite-bracket">]</span></a></sup> If <i>g</i> is the GCD of <i>a</i> and <i>b</i>, then <i>a</i>&nbsp;=&nbsp;<i>mg</i> and <i>b</i>&nbsp;=&nbsp;<i>ng</i> for two coprime numbers <i>m</i> and <i>n</i>. Then
</p>
<dl><dd><span class="texhtml"><i>T</i>(<i>a</i>, <i>b</i>) = <i>T</i>(<i>m</i>, <i>n</i>)</span></dd></dl>
<p>as may be seen by dividing all the steps in the Euclidean algorithm by <i>g</i>.<sup id="cite_ref-98" class="reference"><a href="#cite_note-98"><span class="cite-bracket">[</span>97<span class="cite-bracket">]</span></a></sup> By the same argument, the number of steps remains the same if <i>a</i> and <i>b</i> are multiplied by a common factor <i>w</i>: <i>T</i>(<i>a</i>, <i>b</i>) = <i>T</i>(<i>wa</i>, <i>wb</i>). Therefore, the number of steps <i>T</i> may vary dramatically between neighboring pairs of numbers, such as T(<i>a</i>, <i>b</i>) and T(<i>a</i>,&nbsp;<i>b</i>&nbsp;+&nbsp;1), depending on the size of the two GCDs.
</p><p>The recursive nature of the Euclidean algorithm gives another equation
</p>
<dl><dd><span class="texhtml"><i>T</i>(<i>a</i>, <i>b</i>) = 1 + <i>T</i>(<i>b</i>, <i>r</i><sub>0</sub>) = 2 + <i>T</i>(<i>r</i><sub>0</sub>, <i>r</i><sub>1</sub>) = … = <i>N</i> + <i>T</i>(<i>r</i><sub><i>N</i>−2</sub>, <i>r</i><sub><i>N</i>−1</sub>) = <i>N</i> + 1</span></dd></dl>
<p>where <i>T</i>(<i>x</i>, 0)&nbsp;=&nbsp;0 by assumption.<sup id="cite_ref-Knuth,_p._344_97-1" class="reference"><a href="#cite_note-Knuth,_p._344-97"><span class="cite-bracket">[</span>96<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Worst-case">Worst-case</h4></div>
<p>If the Euclidean algorithm requires <i>N</i> steps for a pair of natural numbers <i>a</i>&nbsp;&gt;&nbsp;<i>b</i>&nbsp;&gt;&nbsp;0, the smallest values of <i>a</i> and <i>b</i> for which this is true are the <a href="Fibonacci_number" class="mw-redirect" title="Fibonacci number">Fibonacci numbers</a> <i>F</i><sub><i>N</i>+2</sub> and <i>F</i><sub><i>N</i>+1</sub>, respectively.<sup id="cite_ref-Knuth,_p._343_99-0" class="reference"><a href="#cite_note-Knuth,_p._343-99"><span class="cite-bracket">[</span>98<span class="cite-bracket">]</span></a></sup> More precisely, if the Euclidean algorithm requires <i>N</i> steps for the pair <i>a</i>&nbsp;&gt;&nbsp;<i>b</i>, then one has <i>a</i>&nbsp;≥&nbsp;<i>F</i><sub><i>N</i>+2</sub> and <i>b</i>&nbsp;≥&nbsp;<i>F</i><sub><i>N</i>+1</sub>. This can be shown by <a href="Mathematical_induction" title="Mathematical induction">induction</a>.<sup id="cite_ref-100" class="reference"><a href="#cite_note-100"><span class="cite-bracket">[</span>99<span class="cite-bracket">]</span></a></sup> If <i>N</i>&nbsp;=&nbsp;1, <i>b</i> divides <i>a</i> with no remainder; the smallest natural numbers for which this is true is <i>b</i>&nbsp;=&nbsp;1 and <i>a</i>&nbsp;=&nbsp;2, which are <i>F</i><sub>2</sub> and <i>F</i><sub>3</sub>, respectively. Now assume that the result holds for all values of <i>N</i> up to <i>M</i>&nbsp;−&nbsp;1. The first step of the <i>M</i>-step algorithm is <i>a</i>&nbsp;=&nbsp;<i>q</i><sub>0</sub><i>b</i>&nbsp;+&nbsp;<i>r</i><sub>0</sub>, and the Euclidean algorithm requires <i>M</i>&nbsp;−&nbsp;1 steps for the pair <i>b</i>&nbsp;&gt;&nbsp;<i>r</i><sub>0</sub>. By induction hypothesis, one has <i>b</i>&nbsp;≥&nbsp;<i>F</i><sub><i>M</i>+1</sub> and <i>r</i><sub>0</sub>&nbsp;≥&nbsp;<i>F</i><sub><i>M</i></sub>. Therefore, <i>a</i>&nbsp;=&nbsp;<i>q</i><sub>0</sub><i>b</i>&nbsp;+&nbsp;<i>r</i><sub>0</sub>&nbsp;≥&nbsp;<i>b</i>&nbsp;+&nbsp;<i>r</i><sub>0</sub>&nbsp;≥&nbsp;<i>F</i><sub><i>M</i>+1</sub>&nbsp;+&nbsp;<i>F</i><sub><i>M</i></sub>&nbsp;=&nbsp;<i>F</i><sub><i>M</i>+2</sub>,
which is the desired inequality.
This proof, published by <a href="Gabriel_Lam%C3%A9" title="Gabriel Lamé">Gabriel Lamé</a> in 1844, represents the beginning of <a href="Computational_complexity_theory" title="Computational complexity theory">computational complexity theory</a>,<sup id="cite_ref-101" class="reference"><a href="#cite_note-101"><span class="cite-bracket">[</span>100<span class="cite-bracket">]</span></a></sup> and also the first practical application of the Fibonacci numbers.<sup id="cite_ref-Knuth,_p._343_99-1" class="reference"><a href="#cite_note-Knuth,_p._343-99"><span class="cite-bracket">[</span>98<span class="cite-bracket">]</span></a></sup>
</p><p>This result suffices to show that the number of steps in Euclid's algorithm can never be more than five times the number of its digits (base 10).<sup id="cite_ref-102" class="reference"><a href="#cite_note-102"><span class="cite-bracket">[</span>101<span class="cite-bracket">]</span></a></sup> For if the algorithm requires <i>N</i> steps, then <i>b</i> is greater than or equal to <i>F</i><sub><i>N</i>+1</sub> which in turn is greater than or equal to <i>φ</i><sup><i>N</i>−1</sup>, where <i>φ</i> is the <a href="Golden_ratio" title="Golden ratio">golden ratio</a>. Since <i>b</i>&nbsp;≥&nbsp;<i>φ</i><sup><i>N</i>−1</sup>, then <i>N</i>&nbsp;−&nbsp;1&nbsp;≤&nbsp;log<sub><i>φ</i></sub><i>b</i>. Since log<sub>10</sub><i>φ</i>&nbsp;&gt;&nbsp;1/5, (<i>N</i>&nbsp;−&nbsp;1)/5&nbsp;&lt;&nbsp;log<sub>10</sub><i>φ</i>&nbsp;log<sub><i>φ</i></sub><i>b</i>&nbsp;=&nbsp;log<sub>10</sub><i>b</i>. Thus, <i>N</i>&nbsp;≤&nbsp;5&nbsp;log<sub>10</sub><i>b</i>. Thus, the Euclidean algorithm always needs less than <a href="Big_O_notation" title="Big O notation"><i>O</i>(<i>h</i>)</a> divisions, where <i>h</i> is the number of digits in the smaller number <i>b</i>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Average">Average</h4></div>
<p>The average number of steps taken by the Euclidean algorithm has been defined in three different ways. The first definition is the average time <i>T</i>(<i>a</i>) required to calculate the GCD of a given number <i>a</i> and a smaller natural number <i>b</i> chosen with equal probability from the integers 0 to <i>a</i>&nbsp;−&nbsp;1<sup id="cite_ref-Knuth,_p._344_97-2" class="reference"><a href="#cite_note-Knuth,_p._344-97"><span class="cite-bracket">[</span>96<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T(a)={\frac {1}{a}}\sum _{0\leq b<a}T(a,b).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>a</mi>
</mfrac>
</mrow>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
<mo>≤<!-- ≤ --></mo>
<mi>b</mi>
<mo>&lt;</mo>
<mi>a</mi>
</mrow>
</munder>
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T(a)={\frac {1}{a}}\sum _{0\leq b&lt;a}T(a,b).}</annotation>
</semantics>
</math></span><img src="./eeb0e84ea4b825926a619f0738568e20d52f9a25.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.338ex; width:22.922ex; height:6.676ex;" alt="{\displaystyle T(a)={\frac {1}{a}}\sum _{0\leq b<a}T(a,b).}" loading="lazy"></span></dd></dl>
<p>However, since <i>T</i>(<i>a</i>,&nbsp;<i>b</i>) fluctuates dramatically with the GCD of the two numbers, the averaged function <i>T</i>(<i>a</i>) is likewise "noisy".<sup id="cite_ref-103" class="reference"><a href="#cite_note-103"><span class="cite-bracket">[</span>102<span class="cite-bracket">]</span></a></sup>
</p><p>To reduce this noise, a second average <i>τ</i>(<i>a</i>) is taken over all numbers coprime with <i>a</i>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau (a)={\frac {1}{\varphi (a)}}\sum _{\begin{smallmatrix}0\leq b<a\\\gcd(a,b)=1\end{smallmatrix}}T(a,b).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>τ<!-- τ --></mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mrow>
<mi>φ<!-- φ --></mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
</mrow>
</mfrac>
</mrow>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mstyle scriptlevel="1">
<mtable rowspacing=".2em" columnspacing="0.333em" displaystyle="false">
<mtr>
<mtd>
<mn>0</mn>
<mo>≤<!-- ≤ --></mo>
<mi>b</mi>
<mo>&lt;</mo>
<mi>a</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mo movablelimits="true" form="prefix">gcd</mo>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mn>1</mn>
</mtd>
</mtr>
</mtable>
</mstyle>
</mrow>
</munder>
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \tau (a)={\frac {1}{\varphi (a)}}\sum _{\begin{smallmatrix}0\leq b&lt;a\\\gcd(a,b)=1\end{smallmatrix}}T(a,b).}</annotation>
</semantics>
</math></span><img src="./1a59110d2108bbad28857056ec51eb6c1c580524.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -5.338ex; width:29.492ex; height:8.676ex;" alt="{\displaystyle \tau (a)={\frac {1}{\varphi (a)}}\sum _{\begin{smallmatrix}0\leq b<a\\\gcd(a,b)=1\end{smallmatrix}}T(a,b).}" loading="lazy"></span></dd></dl>
<p>There are <i>φ</i>(<i>a</i>) coprime integers less than <i>a</i>, where <i>φ</i> is <a href="Euler's_totient_function" title="Euler's totient function">Euler's totient function</a>. This tau average grows smoothly with <i>a</i><sup id="cite_ref-104" class="reference"><a href="#cite_note-104"><span class="cite-bracket">[</span>103<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-105" class="reference"><a href="#cite_note-105"><span class="cite-bracket">[</span>104<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \tau (a)={\frac {12}{\pi ^{2}}}\ln 2\ln a+C+O(a^{-1/6-\varepsilon })}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>τ<!-- τ --></mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>12</mn>
<msup>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mn>2</mn>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mi>a</mi>
<mo>+</mo>
<mi>C</mi>
<mo>+</mo>
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>a</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mn>6</mn>
<mo>−<!-- − --></mo>
<mi>ε<!-- ε --></mi>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \tau (a)={\frac {12}{\pi ^{2}}}\ln 2\ln a+C+O(a^{-1/6-\varepsilon })}</annotation>
</semantics>
</math></span><img src="./977ed1b32dc273f67a46fb6e410666e8acf0289b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.171ex; width:36.664ex; height:5.509ex;" alt="{\displaystyle \tau (a)={\frac {12}{\pi ^{2}}}\ln 2\ln a+C+O(a^{-1/6-\varepsilon })}" loading="lazy"></span></dd></dl>
<p>with the residual error being of order <i>a</i><sup>−(1/6)+<i>ε</i></sup>, where <i>ε</i> is <a href="Infinitesimal" title="Infinitesimal">infinitesimal</a>. The constant <i>C</i> in this formula is called <a href="Porter's_constant" title="Porter's constant">Porter's constant</a><sup id="cite_ref-106" class="reference"><a href="#cite_note-106"><span class="cite-bracket">[</span>105<span class="cite-bracket">]</span></a></sup> and equals
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle C=-{\frac {1}{2}}+{\frac {6\ln 2}{\pi ^{2}}}\left(4\gamma -{\frac {24}{\pi ^{2}}}\zeta '(2)+3\ln 2-2\right)\approx 1.467}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>C</mi>
<mo>=</mo>
<mo>−<!-- − --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mn>6</mn>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mn>2</mn>
</mrow>
<msup>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<mrow>
<mo>(</mo>
<mrow>
<mn>4</mn>
<mi>γ<!-- γ --></mi>
<mo>−<!-- − --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>24</mn>
<msup>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<msup>
<mi>ζ<!-- ζ --></mi>
<mo>′</mo>
</msup>
<mo stretchy="false">(</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mn>3</mn>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mn>2</mn>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
<mo>)</mo>
</mrow>
<mo>≈<!-- ≈ --></mo>
<mn>1.467</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle C=-{\frac {1}{2}}+{\frac {6\ln 2}{\pi ^{2}}}\left(4\gamma -{\frac {24}{\pi ^{2}}}\zeta '(2)+3\ln 2-2\right)\approx 1.467}</annotation>
</semantics>
</math></span><img src="./574e559226f674eed4201564e269c7ad9b8b6555.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:54.736ex; height:6.176ex;" alt="{\displaystyle C=-{\frac {1}{2}}+{\frac {6\ln 2}{\pi ^{2}}}\left(4\gamma -{\frac {24}{\pi ^{2}}}\zeta '(2)+3\ln 2-2\right)\approx 1.467}" loading="lazy"></span></dd></dl>
<p>where <span class="texhtml"><i>γ</i></span> is the <a href="Euler%E2%80%93Mascheroni_constant" class="mw-redirect" title="Euler–Mascheroni constant">Euler–Mascheroni constant</a> and <span class="texhtml"><i>ζ</i><span class="nowrap" style="padding-left:0.15em;">′</span></span> is the <a href="Derivative" title="Derivative">derivative</a> of the <a href="Riemann_zeta_function" title="Riemann zeta function">Riemann zeta function</a>.<sup id="cite_ref-107" class="reference"><a href="#cite_note-107"><span class="cite-bracket">[</span>106<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-108" class="reference"><a href="#cite_note-108"><span class="cite-bracket">[</span>107<span class="cite-bracket">]</span></a></sup> The leading coefficient (12/π<sup>2</sup>) ln 2 was determined by two independent methods.<sup id="cite_ref-109" class="reference"><a href="#cite_note-109"><span class="cite-bracket">[</span>108<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-110" class="reference"><a href="#cite_note-110"><span class="cite-bracket">[</span>109<span class="cite-bracket">]</span></a></sup>
</p><p>Since the first average can be calculated from the tau average by summing over the divisors <i>d</i> of&nbsp;<i>a</i><sup id="cite_ref-111" class="reference"><a href="#cite_note-111"><span class="cite-bracket">[</span>110<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T(a)={\frac {1}{a}}\sum _{d\mid a}\varphi (d)\tau (d)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>a</mi>
</mfrac>
</mrow>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>∣<!-- ∣ --></mo>
<mi>a</mi>
</mrow>
</munder>
<mi>φ<!-- φ --></mi>
<mo stretchy="false">(</mo>
<mi>d</mi>
<mo stretchy="false">)</mo>
<mi>τ<!-- τ --></mi>
<mo stretchy="false">(</mo>
<mi>d</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T(a)={\frac {1}{a}}\sum _{d\mid a}\varphi (d)\tau (d)}</annotation>
</semantics>
</math></span><img src="./b6fdf23824b83cb21d9f4eb0e5f6811c12fe6561.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.505ex; width:22.741ex; height:6.843ex;" alt="{\displaystyle T(a)={\frac {1}{a}}\sum _{d\mid a}\varphi (d)\tau (d)}" loading="lazy"></span></dd></dl>
<p>it can be approximated by the formula<sup id="cite_ref-Norton_1990_112-0" class="reference"><a href="#cite_note-Norton_1990-112"><span class="cite-bracket">[</span>111<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T(a)\approx C+{\frac {12}{\pi ^{2}}}\ln 2\,{\biggl (}{\ln a}-\sum _{d\mid a}{\frac {\Lambda (d)}{d}}{\biggr )}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>≈<!-- ≈ --></mo>
<mi>C</mi>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>12</mn>
<msup>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mn>2</mn>
<mspace width="thinmathspace"></mspace>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-OPEN">
<mo maxsize="2.047em" minsize="2.047em">(</mo>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mi>a</mi>
</mrow>
<mo>−<!-- − --></mo>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>∣<!-- ∣ --></mo>
<mi>a</mi>
</mrow>
</munder>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mi mathvariant="normal">Λ<!-- Λ --></mi>
<mo stretchy="false">(</mo>
<mi>d</mi>
<mo stretchy="false">)</mo>
</mrow>
<mi>d</mi>
</mfrac>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-CLOSE">
<mo maxsize="2.047em" minsize="2.047em">)</mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T(a)\approx C+{\frac {12}{\pi ^{2}}}\ln 2\,{\biggl (}{\ln a}-\sum _{d\mid a}{\frac {\Lambda (d)}{d}}{\biggr )}}</annotation>
</semantics>
</math></span><img src="./57dcbb8dcface89d1bdfe3b1f46581380e8df13e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.505ex; width:38.903ex; height:7.343ex;" alt="{\displaystyle T(a)\approx C+{\frac {12}{\pi ^{2}}}\ln 2\,{\biggl (}{\ln a}-\sum _{d\mid a}{\frac {\Lambda (d)}{d}}{\biggr )}}" loading="lazy"></span></dd></dl>
<p>where Λ(<i>d</i>) is the <a href="Von_Mangoldt_function" title="Von Mangoldt function">Mangoldt function</a>.<sup id="cite_ref-113" class="reference"><a href="#cite_note-113"><span class="cite-bracket">[</span>112<span class="cite-bracket">]</span></a></sup>
</p><p>A third average <i>Y</i>(<i>n</i>) is defined as the mean number of steps required when both <i>a</i> and <i>b</i> are chosen randomly (with uniform distribution) from 1 to <i>n</i><sup id="cite_ref-Norton_1990_112-1" class="reference"><a href="#cite_note-Norton_1990-112"><span class="cite-bracket">[</span>111<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Y(n)={\frac {1}{n^{2}}}\sum _{a=1}^{n}\sum _{b=1}^{n}T(a,b)={\frac {1}{n}}\sum _{a=1}^{n}T(a).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>Y</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<msup>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>a</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</munderover>
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>b</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</munderover>
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo>,</mo>
<mi>b</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<mi>n</mi>
</mfrac>
</mrow>
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>a</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</munderover>
<mi>T</mi>
<mo stretchy="false">(</mo>
<mi>a</mi>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Y(n)={\frac {1}{n^{2}}}\sum _{a=1}^{n}\sum _{b=1}^{n}T(a,b)={\frac {1}{n}}\sum _{a=1}^{n}T(a).}</annotation>
</semantics>
</math></span><img src="./b1daf73a2c348ca3894312d10cbad0b7cc6c015c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:40.72ex; height:6.843ex;" alt="{\displaystyle Y(n)={\frac {1}{n^{2}}}\sum _{a=1}^{n}\sum _{b=1}^{n}T(a,b)={\frac {1}{n}}\sum _{a=1}^{n}T(a).}" loading="lazy"></span></dd></dl>
<p>Substituting the approximate formula for <i>T</i>(<i>a</i>) into this equation yields an estimate for <i>Y</i>(<i>n</i>)<sup id="cite_ref-114" class="reference"><a href="#cite_note-114"><span class="cite-bracket">[</span>113<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Y(n)\approx {\frac {12}{\pi ^{2}}}\ln 2\ln n+0.06.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>Y</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>≈<!-- ≈ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>12</mn>
<msup>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mfrac>
</mrow>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mn>2</mn>
<mi>ln</mi>
<mo>⁡<!-- ⁡ --></mo>
<mi>n</mi>
<mo>+</mo>
<mn>0.06.</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Y(n)\approx {\frac {12}{\pi ^{2}}}\ln 2\ln n+0.06.}</annotation>
</semantics>
</math></span><img src="./90c528cb5f169ef20bc53312c80d3e786634243c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.171ex; width:26.906ex; height:5.509ex;" alt="{\displaystyle Y(n)\approx {\frac {12}{\pi ^{2}}}\ln 2\ln n+0.06.}" loading="lazy"></span></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Computational_expense_per_step">Computational expense per step</h3></div>
<p>In each step <i>k</i> of the Euclidean algorithm, the quotient <i>q</i><sub><i>k</i></sub> and remainder <i>r</i><sub><i>k</i></sub> are computed for a given pair of integers <i>r</i><sub><i>k</i>−2</sub> and <i>r</i><sub><i>k</i>−1</sub>
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i>−2</sub> = <i>q</i><sub><i>k</i></sub> <i>r</i><sub><i>k</i>−1</sub> + <i>r</i><sub><i>k</i></sub>.</span></dd></dl>
<p>The computational expense per step is associated chiefly with finding <i>q</i><sub><i>k</i></sub>, since the remainder <i>r</i><sub><i>k</i></sub> can be calculated quickly from <i>r</i><sub><i>k</i>−2</sub>, <i>r</i><sub><i>k</i>−1</sub>, and <i>q</i><sub><i>k</i></sub>
</p>
<dl><dd><span class="texhtml"><i>r</i><sub><i>k</i></sub> = <i>r</i><sub><i>k</i>−2</sub> − <i>q</i><sub><i>k</i></sub> <i>r</i><sub><i>k</i>−1</sub>.</span></dd></dl>
<p>The computational expense of dividing <i>h</i>-bit numbers scales as <span class="texhtml"><i>O</i>(<i>h</i>(<i>ℓ</i> + 1))</span>, where <span class="texhtml mvar" style="font-style:italic;">ℓ</span> is the length of the quotient.<sup id="cite_ref-Knuth-257-261_94-1" class="reference"><a href="#cite_note-Knuth-257-261-94"><span class="cite-bracket">[</span>93<span class="cite-bracket">]</span></a></sup>
</p><p>For comparison, Euclid's original subtraction-based algorithm can be much slower. A single integer division is equivalent to the quotient <i>q</i> number of subtractions. If the ratio of <i>a</i> and <i>b</i> is very large, the quotient is large and many subtractions will be required. On the other hand, it has been shown that the quotients are very likely to be small integers. The probability of a given quotient <i>q</i> is approximately <span class="texhtml">ln |<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>u</i>/(<i>u</i> − 1)</span>|</span> where <span class="texhtml"><i>u</i> = (<i>q</i> + 1)<sup>2</sup></span>.<sup id="cite_ref-115" class="reference"><a href="#cite_note-115"><span class="cite-bracket">[</span>114<span class="cite-bracket">]</span></a></sup> For illustration, the probability of a quotient of 1, 2, 3, or 4 is roughly 41.5%, 17.0%, 9.3%, and 5.9%, respectively. Since the operation of subtraction is faster than division, particularly for large numbers,<sup id="cite_ref-116" class="reference"><a href="#cite_note-116"><span class="cite-bracket">[</span>115<span class="cite-bracket">]</span></a></sup> the subtraction-based Euclid's algorithm is competitive with the division-based version.<sup id="cite_ref-117" class="reference"><a href="#cite_note-117"><span class="cite-bracket">[</span>116<span class="cite-bracket">]</span></a></sup> This is exploited in the <a href="Binary_GCD_algorithm" title="Binary GCD algorithm">binary version</a> of Euclid's algorithm.<sup id="cite_ref-118" class="reference"><a href="#cite_note-118"><span class="cite-bracket">[</span>117<span class="cite-bracket">]</span></a></sup>
</p><p>Combining the estimated number of steps with the estimated computational expense per step shows that the Euclid's algorithm grows quadratically (<i>h</i><sup>2</sup>) with the average number of digits <i>h</i> in the initial two numbers <i>a</i> and <i>b</i>. Let <span class="texhtml"><i>h</i><sub>0</sub>, <i>h</i><sub>1</sub>, ..., <i>h</i><sub><i>N</i>−1</sub></span> represent the number of digits in the successive remainders <span class="texhtml"><i>r</i><sub>0</sub>, <i>r</i><sub>1</sub>, ..., <i>r</i><sub><i>N</i>−1</sub></span>. Since the number of steps <i>N</i> grows linearly with <i>h</i>, the running time is bounded by
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O{\Big (}\sum _{i<N}h_{i}(h_{i}-h_{i+1}+2){\Big )}\subseteq O{\Big (}h\sum _{i<N}(h_{i}-h_{i+1}+2){\Big )}\subseteq O(h(h_{0}+2N))\subseteq O(h^{2}).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mo maxsize="1.623em" minsize="1.623em">(</mo>
</mrow>
</mrow>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>&lt;</mo>
<mi>N</mi>
</mrow>
</munder>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>−<!-- − --></mo>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>+</mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mo maxsize="1.623em" minsize="1.623em">)</mo>
</mrow>
</mrow>
<mo>⊆<!-- ⊆ --></mo>
<mi>O</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mo maxsize="1.623em" minsize="1.623em">(</mo>
</mrow>
</mrow>
<mi>h</mi>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>&lt;</mo>
<mi>N</mi>
</mrow>
</munder>
<mo stretchy="false">(</mo>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>−<!-- − --></mo>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
<mo>+</mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mo maxsize="1.623em" minsize="1.623em">)</mo>
</mrow>
</mrow>
<mo>⊆<!-- ⊆ --></mo>
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>h</mi>
<mo stretchy="false">(</mo>
<msub>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>+</mo>
<mn>2</mn>
<mi>N</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<mo>⊆<!-- ⊆ --></mo>
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>h</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O{\Big (}\sum _{i&lt;N}h_{i}(h_{i}-h_{i+1}+2){\Big )}\subseteq O{\Big (}h\sum _{i&lt;N}(h_{i}-h_{i+1}+2){\Big )}\subseteq O(h(h_{0}+2N))\subseteq O(h^{2}).}</annotation>
</semantics>
</math></span><img src="./f42bdfff58a9962834d6a5650c867ddcb7d46216.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.171ex; width:81.616ex; height:6.176ex;" alt="{\displaystyle O{\Big (}\sum _{i<N}h_{i}(h_{i}-h_{i+1}+2){\Big )}\subseteq O{\Big (}h\sum _{i<N}(h_{i}-h_{i+1}+2){\Big )}\subseteq O(h(h_{0}+2N))\subseteq O(h^{2}).}" loading="lazy"></span></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Alternative_methods">Alternative methods</h3></div>
<p>Euclid's algorithm is widely used in practice, especially for small numbers, due to its simplicity.<sup id="cite_ref-119" class="reference"><a href="#cite_note-119"><span class="cite-bracket">[</span>118<span class="cite-bracket">]</span></a></sup> For comparison, the efficiency of alternatives to Euclid's algorithm may be determined.
</p><p>One inefficient approach to finding the GCD of two natural numbers <i>a</i> and <i>b</i> is to calculate all their common divisors; the GCD is then the largest common divisor. The common divisors can be found by dividing both numbers by successive integers from 2 to the smaller number <i>b</i>. The number of steps of this approach grows linearly with <i>b</i>, or exponentially in the number of digits. Another inefficient approach is to find the prime factors of one or both numbers. As noted <a href="#Greatest_common_divisor">above</a>, the GCD equals the product of the prime factors shared by the two numbers <i>a</i> and <i>b</i>.<sup id="cite_ref-Schroeder_21_9-1" class="reference"><a href="#cite_note-Schroeder_21-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> Present methods for <a href="Integer_factorization" title="Integer factorization">prime factorization</a> are also inefficient; many modern cryptography systems even rely on that inefficiency.<sup id="cite_ref-Schroeder_216_12-1" class="reference"><a href="#cite_note-Schroeder_216-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p><p>The <a href="Binary_GCD_algorithm" title="Binary GCD algorithm">binary GCD algorithm</a> is an efficient alternative that substitutes division with faster operations by exploiting the <a href="Binary_numeral_system" class="mw-redirect" title="Binary numeral system">binary</a> representation used by computers.<sup id="cite_ref-120" class="reference"><a href="#cite_note-120"><span class="cite-bracket">[</span>119<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-121" class="reference"><a href="#cite_note-121"><span class="cite-bracket">[</span>120<span class="cite-bracket">]</span></a></sup> However, this alternative also scales like <a href="Big-O_notation" class="mw-redirect" title="Big-O notation"><i>O</i>(<i>h</i>²)</a>. It is generally faster than the Euclidean algorithm on real computers, even though it scales in the same way.<sup id="cite_ref-Crandall_2001_95-1" class="reference"><a href="#cite_note-Crandall_2001-95"><span class="cite-bracket">[</span>94<span class="cite-bracket">]</span></a></sup> Additional efficiency can be gleaned by examining only the leading digits of the two numbers <i>a</i> and <i>b</i>.<sup id="cite_ref-122" class="reference"><a href="#cite_note-122"><span class="cite-bracket">[</span>121<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-123" class="reference"><a href="#cite_note-123"><span class="cite-bracket">[</span>122<span class="cite-bracket">]</span></a></sup> The binary algorithm can be extended to other bases (<i>k</i>-ary algorithms),<sup id="cite_ref-124" class="reference"><a href="#cite_note-124"><span class="cite-bracket">[</span>123<span class="cite-bracket">]</span></a></sup> with up to fivefold increases in speed.<sup id="cite_ref-125" class="reference"><a href="#cite_note-125"><span class="cite-bracket">[</span>124<span class="cite-bracket">]</span></a></sup> <a href="Lehmer's_GCD_algorithm" title="Lehmer's GCD algorithm">Lehmer's GCD algorithm</a> uses the same general principle as the binary algorithm to speed up GCD computations in arbitrary bases.
</p><p>A recursive approach for very large integers (with more than 25,000 digits) leads to <a href="Quasilinear_time" class="mw-redirect" title="Quasilinear time">quasilinear</a> integer GCD algorithms,<sup id="cite_ref-126" class="reference"><a href="#cite_note-126"><span class="cite-bracket">[</span>125<span class="cite-bracket">]</span></a></sup> such as those of Schönhage,<sup id="cite_ref-127" class="reference"><a href="#cite_note-127"><span class="cite-bracket">[</span>126<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-128" class="reference"><a href="#cite_note-128"><span class="cite-bracket">[</span>127<span class="cite-bracket">]</span></a></sup> and Stehlé and Zimmermann.<sup id="cite_ref-129" class="reference"><a href="#cite_note-129"><span class="cite-bracket">[</span>128<span class="cite-bracket">]</span></a></sup> These algorithms exploit the 2×2 matrix form of the Euclidean algorithm given <a href="#Matrix_method">above</a>. These quasilinear methods generally scale as <span class="texhtml"><i>O</i>(<i>h</i> log <i>h</i><sup>2</sup> log log <i>h</i>).</span><sup id="cite_ref-Crandall_2001_95-2" class="reference"><a href="#cite_note-Crandall_2001-95"><span class="cite-bracket">[</span>94<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Moller08_96-1" class="reference"><a href="#cite_note-Moller08-96"><span class="cite-bracket">[</span>95<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Generalizations">Generalizations</h2></div>
<p>Although the Euclidean algorithm is used to find the greatest common divisor of two natural numbers (positive integers), it may be generalized to the real numbers, and to other mathematical objects, such as <a href="Polynomial" title="Polynomial">polynomials</a>,<sup id="cite_ref-Lang_1984_130-0" class="reference"><a href="#cite_note-Lang_1984-130"><span class="cite-bracket">[</span>129<span class="cite-bracket">]</span></a></sup> <a href="Quadratic_integer" title="Quadratic integer">quadratic integers</a><sup id="cite_ref-weinberger_131-0" class="reference"><a href="#cite_note-weinberger-131"><span class="cite-bracket">[</span>130<span class="cite-bracket">]</span></a></sup> and <a href="Hurwitz_quaternion" title="Hurwitz quaternion">Hurwitz quaternions</a>.<sup id="cite_ref-stillwell151-152_132-0" class="reference"><a href="#cite_note-stillwell151-152-132"><span class="cite-bracket">[</span>131<span class="cite-bracket">]</span></a></sup> In the latter cases, the Euclidean algorithm is used to demonstrate the crucial property of unique factorization, i.e., that such numbers can be factored uniquely into <a href="Irreducible_element" title="Irreducible element">irreducible elements</a>, the counterparts of prime numbers. Unique factorization is essential to many proofs of number theory.
</p>
<div class="mw-heading mw-heading3"><h3 id="Rational_and_real_numbers">Rational and real numbers</h3></div>
<p>Euclid's algorithm can be applied to <a href="Real_number" title="Real number">real numbers</a>, as described by Euclid in Book 10 of his <i><a href="Euclid's_Elements" title="Euclid's Elements">Elements</a></i>. The goal of the algorithm is to identify a real number <span class="texhtml mvar" style="font-style:italic;">g</span> such that two given real numbers, <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span>, are integer multiples of it: <span class="texhtml"><i>a</i> = <i>mg</i></span> and <span class="texhtml"><i>b</i> = <i>ng</i></span>, where <span class="texhtml mvar" style="font-style:italic;">m</span> and <span class="texhtml mvar" style="font-style:italic;">n</span> are <a href="Integer" title="Integer">integers</a>.<sup id="cite_ref-Weil_1983_29-1" class="reference"><a href="#cite_note-Weil_1983-29"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup> This identification is equivalent to finding an <a href="Integer_relation_algorithm" title="Integer relation algorithm">integer relation</a> among the real numbers <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span>; that is, it determines integers <span class="texhtml mvar" style="font-style:italic;">s</span> and <span class="texhtml mvar" style="font-style:italic;">t</span> such that <span class="texhtml"><i>sa</i> + <i>tb</i> = 0</span>. If such an equation is possible, <i>a</i> and <i>b</i> are called commensurable lengths, otherwise they are <a href="Commensurability_(mathematics)" title="Commensurability (mathematics)">incommensurable lengths</a>.<sup id="cite_ref-133" class="reference"><a href="#cite_note-133"><span class="cite-bracket">[</span>132<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-134" class="reference"><a href="#cite_note-134"><span class="cite-bracket">[</span>133<span class="cite-bracket">]</span></a></sup>
</p><p>The real-number Euclidean algorithm differs from its integer counterpart in two respects. First, the remainders <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> are real numbers, although the quotients <span class="texhtml"><i>q</i><sub><i>k</i></sub></span> are integers as before. Second, the algorithm is not guaranteed to end in a finite number <span class="texhtml mvar" style="font-style:italic;">N</span> of steps. If it does, the fraction <span class="texhtml"><i>a</i>/<i>b</i></span> is a rational number, i.e., the ratio of two integers
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\frac {a}{b}}={\frac {mg}{ng}}={\frac {m}{n}},}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mi>m</mi>
<mi>g</mi>
</mrow>
<mrow>
<mi>n</mi>
<mi>g</mi>
</mrow>
</mfrac>
</mrow>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>m</mi>
<mi>n</mi>
</mfrac>
</mrow>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\frac {a}{b}}={\frac {mg}{ng}}={\frac {m}{n}},}</annotation>
</semantics>
</math></span><img src="./ebe70bc1e1fa440faa4c9029ff65f0947ae83e64.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.338ex; width:15.779ex; height:5.343ex;" alt="{\displaystyle {\frac {a}{b}}={\frac {mg}{ng}}={\frac {m}{n}},}" loading="lazy"></span></dd></dl>
<p>and can be written as a finite continued fraction <span class="texhtml">[<i>q</i><sub>0</sub>; <i>q</i><sub>1</sub>, <i>q</i><sub>2</sub>, ..., <i>q</i><sub><i>N</i></sub>]</span>. If the algorithm does not stop, the fraction <span class="texhtml"><i>a</i>/<i>b</i></span> is an <a href="Irrational_number" title="Irrational number">irrational number</a> and can be described by an infinite continued fraction <span class="texhtml">[<i>q</i><sub>0</sub>; <i>q</i><sub>1</sub>, <i>q</i><sub>2</sub>, …]</span>.<sup id="cite_ref-135" class="reference"><a href="#cite_note-135"><span class="cite-bracket">[</span>134<span class="cite-bracket">]</span></a></sup> Examples of infinite continued fractions are the <a href="Golden_ratio" title="Golden ratio">golden ratio</a> <span class="texhtml"><i>φ</i> = [1; 1, 1, ...]</span> and the <a href="Square_root_of_2" title="Square root of 2">square root of two</a>, <span class="texhtml"><span class="nowrap">√<span style="border-top:1px solid; padding:0 0.1em;">2</span></span> = [1; 2, 2, ...]</span>.<sup id="cite_ref-136" class="reference"><a href="#cite_note-136"><span class="cite-bracket">[</span>135<span class="cite-bracket">]</span></a></sup> When applied to two arbitrary real numbers, the algorithm is unlikely to stop, since <a href="Almost_all" title="Almost all">almost all</a> ratios <span class="texhtml"><i>a</i>/<i>b</i></span> of two real numbers are irrational.<sup id="cite_ref-137" class="reference"><a href="#cite_note-137"><span class="cite-bracket">[</span>136<span class="cite-bracket">]</span></a></sup>
</p><p>An infinite continued fraction may be truncated at a step <span class="texhtml"><i>k</i> [<i>q</i><sub>0</sub>; <i>q</i><sub>1</sub>, <i>q</i><sub>2</sub>, ..., <i>q</i><sub><i>k</i></sub>]</span> to yield an approximation to <span class="texhtml"><i>a</i>/<i>b</i></span> that improves as <span class="texhtml mvar" style="font-style:italic;">k</span> is increased. The approximation is described by <a href="Convergent_(continued_fraction)" class="mw-redirect" title="Convergent (continued fraction)">convergents</a> <span class="texhtml"><i>m</i><sub><i>k</i></sub>/<i>n</i><sub><i>k</i></sub></span>; the numerator and denominators are coprime and obey the <a href="Recurrence_relation" title="Recurrence relation">recurrence relation</a>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}m_{k}&amp;=q_{k}m_{k-1}+m_{k-2}\\n_{k}&amp;=q_{k}n_{k-1}+n_{k-2},\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<msub>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>+</mo>
<msub>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>,</mo>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}m_{k}&amp;=q_{k}m_{k-1}+m_{k-2}\\n_{k}&amp;=q_{k}n_{k-1}+n_{k-2},\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./c2246f4f03913cc9726e4924ecc9776513ec7136.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.111ex; margin-bottom: -0.227ex; width:22.405ex; height:5.843ex;" alt="{\displaystyle {\begin{aligned}m_{k}&amp;=q_{k}m_{k-1}+m_{k-2}\\n_{k}&amp;=q_{k}n_{k-1}+n_{k-2},\end{aligned}}}" loading="lazy"></span></dd></dl>
<p>where <span class="texhtml"><i>m</i><sub>−1</sub> = <i>n</i><sub>−2</sub> = 1</span> and <span class="texhtml"><i>m</i><sub>−2</sub> = <i>n</i><sub>−1</sub> = 0</span> are the initial values of the recursion. The convergent <span class="texhtml"><i>m</i><sub><i>k</i></sub>/<i>n</i><sub><i>k</i></sub></span> is the best <a href="Rational_number" title="Rational number">rational number</a> approximation to <span class="texhtml"><i>a</i>/<i>b</i></span> with denominator <span class="texhtml"><i>n</i><sub><i>k</i></sub></span>:<sup id="cite_ref-138" class="reference"><a href="#cite_note-138"><span class="cite-bracket">[</span>137<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \left|{\frac {a}{b}}-{\frac {m_{k}}{n_{k}}}\right|<{\frac {1}{n_{k}^{2}}}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow>
<mo>|</mo>
<mrow>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mi>a</mi>
<mi>b</mi>
</mfrac>
</mrow>
<mo>−<!-- − --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msub>
<mi>m</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<msub>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
</mfrac>
</mrow>
</mrow>
<mo>|</mo>
</mrow>
<mo>&lt;</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mn>1</mn>
<msubsup>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msubsup>
</mfrac>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \left|{\frac {a}{b}}-{\frac {m_{k}}{n_{k}}}\right|&lt;{\frac {1}{n_{k}^{2}}}.}</annotation>
</semantics>
</math></span><img src="./f2d2e3ea02f68f2bfe4a20aabff8d92dace95747.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:17.23ex; height:6.343ex;" alt="{\displaystyle \left|{\frac {a}{b}}-{\frac {m_{k}}{n_{k}}}\right|<{\frac {1}{n_{k}^{2}}}.}" loading="lazy"></span></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Polynomials">Polynomials</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Polynomial_greatest_common_divisor" title="Polynomial greatest common divisor">Polynomial greatest common divisor</a></div>
<p>Polynomials in a single variable <i>x</i> can be added, multiplied and factored into <a href="Irreducible_polynomial" title="Irreducible polynomial">irreducible polynomials</a>, which are the analogs of the prime numbers for integers. The greatest common divisor polynomial <span class="texhtml"><i>g</i>(<i>x</i>)</span> of two polynomials <span class="texhtml"><i>a</i>(<i>x</i>)</span> and <span class="texhtml"><i>b</i>(<i>x</i>)</span> is defined as the product of their shared irreducible polynomials, which can be identified using the Euclidean algorithm.<sup id="cite_ref-Lang_1984_130-1" class="reference"><a href="#cite_note-Lang_1984-130"><span class="cite-bracket">[</span>129<span class="cite-bracket">]</span></a></sup> The basic procedure is similar to that for integers. At each step <span class="texhtml mvar" style="font-style:italic;">k</span>, a quotient polynomial <span class="texhtml"><i>q</i><sub><i>k</i></sub>(<i>x</i>)</span> and a remainder polynomial <span class="texhtml"><i>r</i><sub><i>k</i></sub>(<i>x</i>)</span> are identified to satisfy the recursive equation
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k-2}(x)=q_{k}(x)r_{k-1}(x)+r_{k}(x),}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>+</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k-2}(x)=q_{k}(x)r_{k-1}(x)+r_{k}(x),}</annotation>
</semantics>
</math></span><img src="./9a124a8ba0c2bafb28022d39fda1b09864b696b1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:31.881ex; height:2.843ex;" alt="{\displaystyle r_{k-2}(x)=q_{k}(x)r_{k-1}(x)+r_{k}(x),}" loading="lazy"></span></dd></dl>
<p>where <span class="texhtml"><i>r</i><sub>−2</sub>(<i>x</i>) = <i>a</i>(<i>x</i>)</span> and <span class="texhtml"><i>r</i><sub>−1</sub>(<i>x</i>) = <i>b</i>(<i>x</i>)</span>. Each quotient polynomial is chosen such that each remainder is either zero or has a degree that is smaller than the degree of its predecessor: <span class="texhtml">deg[<i>r</i><sub><i>k</i></sub>(<i>x</i>)] &lt; deg[<i>r</i><sub><i>k</i>−1</sub>(<i>x</i>)]</span>. Since the degree is a nonnegative integer, and since it decreases with every step, the Euclidean algorithm concludes in a finite number of steps. The last nonzero remainder is the greatest common divisor of the original two polynomials, <span class="texhtml"><i>a</i>(<i>x</i>)</span> and <span class="texhtml"><i>b</i>(<i>x</i>)</span>.<sup id="cite_ref-139" class="reference"><a href="#cite_note-139"><span class="cite-bracket">[</span>138<span class="cite-bracket">]</span></a></sup>
</p><p>For example, consider the following two quartic polynomials, which each factor into two quadratic polynomials
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}a(x)&amp;=x^{4}-4x^{3}+4x^{2}-3x+14=(x^{2}-5x+7)(x^{2}+x+2)\qquad {\text{and}}\\b(x)&amp;=x^{4}+8x^{3}+12x^{2}+17x+6=(x^{2}+7x+3)(x^{2}+x+2).\end{aligned}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true">
<mtr>
<mtd>
<mi>a</mi>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>4</mn>
</mrow>
</msup>
<mo>−<!-- − --></mo>
<mn>4</mn>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
</mrow>
</msup>
<mo>+</mo>
<mn>4</mn>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>−<!-- − --></mo>
<mn>3</mn>
<mi>x</mi>
<mo>+</mo>
<mn>14</mn>
<mo>=</mo>
<mo stretchy="false">(</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>−<!-- − --></mo>
<mn>5</mn>
<mi>x</mi>
<mo>+</mo>
<mn>7</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>+</mo>
<mi>x</mi>
<mo>+</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mspace width="2em"></mspace>
<mrow class="MJX-TeXAtom-ORD">
<mtext>and</mtext>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>b</mi>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
</mtd>
<mtd>
<mi></mi>
<mo>=</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>4</mn>
</mrow>
</msup>
<mo>+</mo>
<mn>8</mn>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>3</mn>
</mrow>
</msup>
<mo>+</mo>
<mn>12</mn>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>+</mo>
<mn>17</mn>
<mi>x</mi>
<mo>+</mo>
<mn>6</mn>
<mo>=</mo>
<mo stretchy="false">(</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>+</mo>
<mn>7</mn>
<mi>x</mi>
<mo>+</mo>
<mn>3</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<msup>
<mi>x</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo>+</mo>
<mi>x</mi>
<mo>+</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}a(x)&amp;=x^{4}-4x^{3}+4x^{2}-3x+14=(x^{2}-5x+7)(x^{2}+x+2)\qquad {\text{and}}\\b(x)&amp;=x^{4}+8x^{3}+12x^{2}+17x+6=(x^{2}+7x+3)(x^{2}+x+2).\end{aligned}}}</annotation>
</semantics>
</math></span><img src="./5017293fab5cb800af9c776f0b133f45674850dd.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.671ex; width:71.26ex; height:6.509ex;" alt="{\displaystyle {\begin{aligned}a(x)&amp;=x^{4}-4x^{3}+4x^{2}-3x+14=(x^{2}-5x+7)(x^{2}+x+2)\qquad {\text{and}}\\b(x)&amp;=x^{4}+8x^{3}+12x^{2}+17x+6=(x^{2}+7x+3)(x^{2}+x+2).\end{aligned}}}" loading="lazy"></span></dd></dl>
<p><a href="Polynomial_long_division" title="Polynomial long division">Dividing</a> <span class="texhtml"><i>a</i>(<i>x</i>)</span> by <span class="texhtml"><i>b</i>(<i>x</i>)</span> yields a remainder <span class="texhtml"><i>r</i><sub>0</sub>(<i>x</i>) = <i>x</i><sup>3</sup> + (2/3)<i>x</i><sup>2</sup> + (5/3)<i>x</i> − (2/3)</span>. In the next step, <span class="texhtml"><i>b</i>(<i>x</i>)</span> is divided by <span class="texhtml"><i>r</i><sub>0</sub>(<i>x</i>)</span> yielding a remainder <span class="texhtml"><i>r</i><sub>1</sub>(<i>x</i>) = <i>x</i><sup>2</sup> + <i>x</i> + 2</span>. Finally, dividing <span class="texhtml"><i>r</i><sub>0</sub>(<i>x</i>)</span> by <span class="texhtml"><i>r</i><sub>1</sub>(<i>x</i>)</span> yields a zero remainder, indicating that <span class="texhtml"><i>r</i><sub>1</sub>(<i>x</i>)</span> is the greatest common divisor polynomial of <span class="texhtml"><i>a</i>(<i>x</i>)</span> and <span class="texhtml"><i>b</i>(<i>x</i>)</span>, consistent with their factorization.
</p><p>Many of the applications described above for integers carry over to polynomials.<sup id="cite_ref-140" class="reference"><a href="#cite_note-140"><span class="cite-bracket">[</span>139<span class="cite-bracket">]</span></a></sup> The Euclidean algorithm can be used to solve linear Diophantine equations and Chinese remainder problems for polynomials; continued fractions of polynomials can also be defined.
</p><p>The polynomial Euclidean algorithm has other applications, such as <a href="Sturm_chain" class="mw-redirect" title="Sturm chain">Sturm chains</a>, a method for counting the <a href="Zero_of_a_function" title="Zero of a function">zeros of a polynomial</a> that lie inside a given <a href="Interval_(mathematics)" title="Interval (mathematics)">real interval</a>.<sup id="cite_ref-141" class="reference"><a href="#cite_note-141"><span class="cite-bracket">[</span>140<span class="cite-bracket">]</span></a></sup> This in turn has applications in several areas, such as the <a href="Routh%E2%80%93Hurwitz_stability_criterion" title="Routh–Hurwitz stability criterion">Routh–Hurwitz stability criterion</a> in <a href="Control_theory" title="Control theory">control theory</a>.<sup id="cite_ref-142" class="reference"><a href="#cite_note-142"><span class="cite-bracket">[</span>141<span class="cite-bracket">]</span></a></sup>
</p><p>Finally, the coefficients of the polynomials need not be drawn from integers, real numbers or even the complex numbers. For example, the coefficients may be drawn from a general field, such as the finite fields <span class="texhtml">GF(<i>p</i>)</span> described above. The corresponding conclusions about the Euclidean algorithm and its applications hold even for such polynomials.<sup id="cite_ref-Lang_1984_130-2" class="reference"><a href="#cite_note-Lang_1984-130"><span class="cite-bracket">[</span>129<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Gaussian_integers">Gaussian integers</h3></div>

<p>The <a href="Gaussian_integer" title="Gaussian integer">Gaussian integers</a> are <a href="Complex_number" title="Complex number">complex numbers</a> of the form <span class="texhtml"><i>α</i> = <i>u</i> + <i>vi</i></span>, where <span class="texhtml mvar" style="font-style:italic;">u</span> and <span class="texhtml mvar" style="font-style:italic;">v</span> are ordinary <a href="Integer" title="Integer">integers</a><sup id="cite_ref-143" class="reference"><a href="#cite_note-143"><span class="cite-bracket">[</span>note 2<span class="cite-bracket">]</span></a></sup> and <span class="texhtml mvar" style="font-style:italic;">i</span> is the <a href="Imaginary_unit" title="Imaginary unit">square root of negative one</a>.<sup id="cite_ref-Stillwell_2003_144-0" class="reference"><a href="#cite_note-Stillwell_2003-144"><span class="cite-bracket">[</span>142<span class="cite-bracket">]</span></a></sup> By defining an analog of the Euclidean algorithm, Gaussian integers can be shown to be uniquely factorizable, by the argument <a href="#Bézout's_identity">above</a>.<sup id="cite_ref-Gauss_1832_44-1" class="reference"><a href="#cite_note-Gauss_1832-44"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup> This unique factorization is helpful in many applications, such as deriving all <a href="Pythagorean_triple" title="Pythagorean triple">Pythagorean triples</a> or proving <a href="Fermat's_theorem_on_sums_of_two_squares" title="Fermat's theorem on sums of two squares">Fermat's theorem on sums of two squares</a>.<sup id="cite_ref-Stillwell_2003_144-1" class="reference"><a href="#cite_note-Stillwell_2003-144"><span class="cite-bracket">[</span>142<span class="cite-bracket">]</span></a></sup> In general, the Euclidean algorithm is convenient in such applications, but not essential; for example, the theorems can often be proven by other arguments.
</p><p>The Euclidean algorithm developed for two Gaussian integers <span class="texhtml mvar" style="font-style:italic;">α</span> and <span class="texhtml mvar" style="font-style:italic;">β</span> is nearly the same as that for ordinary integers,<sup id="cite_ref-hensley_145-0" class="reference"><a href="#cite_note-hensley-145"><span class="cite-bracket">[</span>143<span class="cite-bracket">]</span></a></sup> but differs in two respects. As before, we set <span class="texhtml"><i>r</i><sub>−2</sub> = <i>α</i></span> and <span class="texhtml"><i>r</i><sub>−1</sub> = <i>β</i></span>, and the task at each step <span class="texhtml mvar" style="font-style:italic;">k</span> is to identify a quotient <span class="texhtml"><i>q</i><sub><i>k</i></sub></span> and a remainder <span class="texhtml"><i>r</i><sub><i>k</i></sub></span> such that
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r_{k}=r_{k-2}-q_{k}r_{k-1},}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>2</mn>
</mrow>
</msub>
<mo>−<!-- − --></mo>
<msub>
<mi>q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<msub>
<mi>r</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r_{k}=r_{k-2}-q_{k}r_{k-1},}</annotation>
</semantics>
</math></span><img src="./4d869488f195aa53279b6ed587a3537815c4ed51.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:19.325ex; height:2.343ex;" alt="{\displaystyle r_{k}=r_{k-2}-q_{k}r_{k-1},}" loading="lazy"></span></dd></dl>
<p>where every remainder is strictly smaller than its predecessor: <span class="texhtml">|<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i></sub></span>| &lt; |<span class="nowrap" style="padding-left:0.1em; padding-right:0.1em;"><i>r</i><sub><i>k</i>−1</sub></span>|</span>. The first difference is that the quotients and remainders are themselves Gaussian integers, and thus are <a href="Complex_number" title="Complex number">complex numbers</a>. The quotients <span class="texhtml"><i>q</i><sub><i>k</i></sub></span> are generally found by rounding the real and complex parts of the exact ratio (such as the complex number <span class="texhtml"><i>α</i>/<i>β</i></span>) to the nearest integers.<sup id="cite_ref-hensley_145-1" class="reference"><a href="#cite_note-hensley-145"><span class="cite-bracket">[</span>143<span class="cite-bracket">]</span></a></sup> The second difference lies in the necessity of defining how one complex remainder can be "smaller" than another. To do this, a <a href="Norm_(mathematics)" title="Norm (mathematics)">norm function</a> <span class="texhtml"><i>f</i>(<i>u</i> + <i>vi</i>) = <i>u</i><sup>2</sup> + <i>v</i><sup>2</sup></span> is defined, which converts every Gaussian integer <span class="texhtml"><i>u</i> + <i>vi</i></span> into an ordinary integer. After each step <span class="texhtml mvar" style="font-style:italic;">k</span> of the Euclidean algorithm, the norm of the remainder <span class="texhtml"><i>f</i>(<i>r</i><sub><i>k</i></sub>)</span> is smaller than the norm of the preceding remainder, <span class="texhtml"><i>f</i>(<i>r</i><sub><i>k</i>−1</sub>)</span>. Since the norm is a nonnegative integer and decreases with every step, the Euclidean algorithm for Gaussian integers ends in a finite number of steps.<sup id="cite_ref-146" class="reference"><a href="#cite_note-146"><span class="cite-bracket">[</span>144<span class="cite-bracket">]</span></a></sup> The final nonzero remainder is <span class="texhtml">gcd(<i>α</i>, <i>β</i>)</span>, the Gaussian integer of largest norm that divides both <span class="texhtml mvar" style="font-style:italic;">α</span> and <span class="texhtml mvar" style="font-style:italic;">β</span>; it is unique up to multiplication by a unit, <span class="texhtml">±1</span> or <span class="texhtml">±<i>i</i></span>.<sup id="cite_ref-147" class="reference"><a href="#cite_note-147"><span class="cite-bracket">[</span>145<span class="cite-bracket">]</span></a></sup>
</p><p>Many of the other applications of the Euclidean algorithm carry over to Gaussian integers. For example, it can be used to solve linear Diophantine equations and Chinese remainder problems for Gaussian integers;<sup id="cite_ref-148" class="reference"><a href="#cite_note-148"><span class="cite-bracket">[</span>146<span class="cite-bracket">]</span></a></sup> continued fractions of Gaussian integers can also be defined.<sup id="cite_ref-hensley_145-2" class="reference"><a href="#cite_note-hensley-145"><span class="cite-bracket">[</span>143<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Euclidean_domains">Euclidean domains</h3></div>
<p>A set of elements under two <a href="Binary_operation" title="Binary operation">binary operations</a>, denoted as addition and multiplication, is called a <a href="Euclidean_domain" title="Euclidean domain">Euclidean domain</a> if it forms a <a href="Commutative_ring" title="Commutative ring">commutative ring</a> <span class="texhtml mvar" style="font-style:italic;">R</span> and, roughly speaking, if a generalized Euclidean algorithm can be performed on them.<sup id="cite_ref-149" class="reference"><a href="#cite_note-149"><span class="cite-bracket">[</span>147<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-150" class="reference"><a href="#cite_note-150"><span class="cite-bracket">[</span>148<span class="cite-bracket">]</span></a></sup> The two operations of such a ring need not be the addition and multiplication of ordinary arithmetic; rather, they can be more general, such as the operations of a <a href="Group_(mathematics)" title="Group (mathematics)">mathematical group</a> or <a href="Monoid" title="Monoid">monoid</a>. Nevertheless, these general operations should respect many of the laws governing ordinary arithmetic, such as <a href="Commutative_property" title="Commutative property">commutativity</a>, <a href="Associative_property" title="Associative property">associativity</a> and <a href="Distributive_property" title="Distributive property">distributivity</a>.
</p><p>The generalized Euclidean algorithm requires a <i>Euclidean function</i>, i.e., a mapping <span class="texhtml mvar" style="font-style:italic;">f</span> from <span class="texhtml mvar" style="font-style:italic;">R</span> into the set of nonnegative integers such that, for any two nonzero elements <span class="texhtml mvar" style="font-style:italic;">a</span> and <span class="texhtml mvar" style="font-style:italic;">b</span> in <span class="texhtml mvar" style="font-style:italic;">R</span>, there exist <span class="texhtml mvar" style="font-style:italic;">q</span> and <span class="texhtml mvar" style="font-style:italic;">r</span> in <span class="texhtml mvar" style="font-style:italic;">R</span> such that <span class="texhtml"><i>a</i> = <i>qb</i> + <i>r</i></span> and <span class="texhtml"><i>f</i>(<i>r</i>) &lt; <i>f</i>(<i>b</i>)</span>.<sup id="cite_ref-151" class="reference"><a href="#cite_note-151"><span class="cite-bracket">[</span>149<span class="cite-bracket">]</span></a></sup> Examples of such mappings are the absolute value for integers, the degree for <a href="Univariate_polynomial" class="mw-redirect" title="Univariate polynomial">univariate polynomials</a>, and the norm for Gaussian integers <a href="#Gaussian_integers">above</a>.<sup id="cite_ref-152" class="reference"><a href="#cite_note-152"><span class="cite-bracket">[</span>150<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-153" class="reference"><a href="#cite_note-153"><span class="cite-bracket">[</span>151<span class="cite-bracket">]</span></a></sup> The basic principle is that each step of the algorithm reduces <i>f</i> inexorably; hence, if <span class="texhtml mvar" style="font-style:italic;">f</span> can be reduced only a finite number of times, the algorithm must stop in a finite number of steps. This principle relies on the <a href="Well-order" title="Well-order">well-ordering</a> property of the non-negative integers, which asserts that every non-empty set of non-negative integers has a smallest member.<sup id="cite_ref-sharpe_154-0" class="reference"><a href="#cite_note-sharpe-154"><span class="cite-bracket">[</span>152<span class="cite-bracket">]</span></a></sup>
</p><p>The <a href="Fundamental_theorem_of_arithmetic" title="Fundamental theorem of arithmetic">fundamental theorem of arithmetic</a> applies to any Euclidean domain: Any number from a Euclidean domain can be factored uniquely into <a href="Irreducible_element" title="Irreducible element">irreducible elements</a>. Any Euclidean domain is a <a href="Unique_factorization_domain" title="Unique factorization domain">unique factorization domain</a> (UFD), although the converse is not true.<sup id="cite_ref-sharpe_154-1" class="reference"><a href="#cite_note-sharpe-154"><span class="cite-bracket">[</span>152<span class="cite-bracket">]</span></a></sup> The Euclidean domains and the UFD's are subclasses of the <a href="GCD_domain" title="GCD domain">GCD domains</a>, domains in which a greatest common divisor of two numbers always exists.<sup id="cite_ref-155" class="reference"><a href="#cite_note-155"><span class="cite-bracket">[</span>153<span class="cite-bracket">]</span></a></sup> In other words, a greatest common divisor may exist (for all pairs of elements in a domain), although it may not be possible to find it using a Euclidean algorithm. A Euclidean domain is always a <a href="Principal_ideal_domain" title="Principal ideal domain">principal ideal domain</a> (PID), an <a href="Integral_domain" title="Integral domain">integral domain</a> in which every <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideal</a> is a <a href="Principal_ideal" title="Principal ideal">principal ideal</a>.<sup id="cite_ref-156" class="reference"><a href="#cite_note-156"><span class="cite-bracket">[</span>154<span class="cite-bracket">]</span></a></sup> Again, the converse is not true: not every PID is a Euclidean domain.
</p><p>The unique factorization of Euclidean domains is useful in many applications. For example, the unique factorization of the Gaussian integers is convenient in deriving formulae for all <a href="Pythagorean_triple" title="Pythagorean triple">Pythagorean triples</a> and in proving <a href="Fermat's_theorem_on_sums_of_two_squares" title="Fermat's theorem on sums of two squares">Fermat's theorem on sums of two squares</a>.<sup id="cite_ref-Stillwell_2003_144-2" class="reference"><a href="#cite_note-Stillwell_2003-144"><span class="cite-bracket">[</span>142<span class="cite-bracket">]</span></a></sup> Unique factorization was also a key element in an attempted proof of <a href="Fermat's_Last_Theorem" title="Fermat's Last Theorem">Fermat's Last Theorem</a> published in 1847 by Gabriel Lamé, the same mathematician who analyzed the efficiency of Euclid's algorithm, based on a suggestion of <a href="Joseph_Liouville" title="Joseph Liouville">Joseph Liouville</a>.<sup id="cite_ref-157" class="reference"><a href="#cite_note-157"><span class="cite-bracket">[</span>155<span class="cite-bracket">]</span></a></sup> Lamé's approach required the unique factorization of numbers of the form <span class="texhtml"><i>x</i> + <i>ωy</i></span>, where <span class="texhtml mvar" style="font-style:italic;">x</span> and <span class="texhtml mvar" style="font-style:italic;">y</span> are integers, and <span class="texhtml"><i>ω</i> = <i>e</i><sup>2<i>iπ</i>/<i>n</i></sup></span> is an <span class="texhtml mvar" style="font-style:italic;">n</span>th root of 1, that is, <span class="texhtml"><i>ω</i><sup><i>n</i></sup> = 1</span>. Although this approach succeeds for some values of <span class="texhtml mvar" style="font-style:italic;">n</span> (such as <span class="texhtml"><i>n</i> = 3</span>, the <a href="Eisenstein_integer" title="Eisenstein integer">Eisenstein integers</a>), in general such numbers do <em>not</em> factor uniquely. This failure of unique factorization in some <a href="Cyclotomic_field" title="Cyclotomic field">cyclotomic fields</a> led <a href="Ernst_Kummer" title="Ernst Kummer">Ernst Kummer</a> to the concept of <a href="Ideal_number" title="Ideal number">ideal numbers</a> and, later, <a href="Richard_Dedekind" title="Richard Dedekind">Richard Dedekind</a> to <a href="Ideal_(ring_theory)" title="Ideal (ring theory)">ideals</a>.<sup id="cite_ref-158" class="reference"><a href="#cite_note-158"><span class="cite-bracket">[</span>156<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Unique_factorization_of_quadratic_integers">Unique factorization of quadratic integers</h4></div>

<p>The <a href="Quadratic_integer" title="Quadratic integer">quadratic integer</a> rings are helpful to illustrate Euclidean domains. Quadratic integers are generalizations of the Gaussian integers in which the <a href="Imaginary_unit" title="Imaginary unit">imaginary unit</a> <i>i</i> is replaced by a number <span class="texhtml mvar" style="font-style:italic;">ω</span>. Thus, they have the form <span class="texhtml"><i>u</i> + <i>vω</i></span>, where <span class="texhtml mvar" style="font-style:italic;">u</span> and <span class="texhtml mvar" style="font-style:italic;">v</span> are integers and <span class="texhtml mvar" style="font-style:italic;">ω</span> has one of two forms, depending on a parameter <span class="texhtml mvar" style="font-style:italic;">D</span>. If <span class="texhtml mvar" style="font-style:italic;">D</span> does not equal a multiple of four plus one, then
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ={\sqrt {D}}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>ω<!-- ω --></mi>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>D</mi>
</msqrt>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \omega ={\sqrt {D}}.}</annotation>
</semantics>
</math></span><img src="./0a727dc9de031c71ccacf6617ac07a816ed3ba3b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:9.051ex; height:3.009ex;" alt="{\displaystyle \omega ={\sqrt {D}}.}" loading="lazy"></span></dd></dl>
<p>If, however, <span class="texhtml"><i>D</i></span> does equal a multiple of four plus one, then
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ={\frac {1+{\sqrt {D}}}{2}}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>ω<!-- ω --></mi>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mn>1</mn>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>D</mi>
</msqrt>
</mrow>
</mrow>
<mn>2</mn>
</mfrac>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \omega ={\frac {1+{\sqrt {D}}}{2}}.}</annotation>
</semantics>
</math></span><img src="./cd3f1793eef655097a24765d6b48d950a45302ea.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:13.89ex; height:5.843ex;" alt="{\displaystyle \omega ={\frac {1+{\sqrt {D}}}{2}}.}" loading="lazy"></span></dd></dl>
<p>If the function <span class="texhtml mvar" style="font-style:italic;">f</span> corresponds to a <a href="Field_norm" title="Field norm">norm</a> function, such as that used to order the Gaussian integers <a href="#Gaussian_integers">above</a>, then the domain is known as <i><a href="Norm-Euclidean_field" class="mw-redirect" title="Norm-Euclidean field">norm-Euclidean</a></i>. The norm-Euclidean rings of quadratic integers are exactly those where <span class="texhtml mvar" style="font-style:italic;">D</span> is one of the values −11, −7, −3, −2, −1, 2, 3, 5, 6, 7, 11, 13, 17, 19, 21, 29, 33, 37, 41, 57, or 73.<sup id="cite_ref-159" class="reference"><a href="#cite_note-159"><span class="cite-bracket">[</span>157<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-160" class="reference"><a href="#cite_note-160"><span class="cite-bracket">[</span>158<span class="cite-bracket">]</span></a></sup> The cases <span class="texhtml"><i>D</i> = −1</span> and <span class="texhtml"><i>D</i> = −3</span> yield the <a href="Gaussian_integer" title="Gaussian integer">Gaussian integers</a> and <a href="Eisenstein_integer" title="Eisenstein integer">Eisenstein integers</a>, respectively.
</p><p>If <span class="texhtml mvar" style="font-style:italic;">f</span> is allowed to be any Euclidean function, then the list of possible values of <span class="texhtml mvar" style="font-style:italic;">D</span> for which the domain is Euclidean is not yet known.<sup id="cite_ref-Clark_1994_161-0" class="reference"><a href="#cite_note-Clark_1994-161"><span class="cite-bracket">[</span>159<span class="cite-bracket">]</span></a></sup> The first example of a Euclidean domain that was not norm-Euclidean (with <span class="texhtml"><i>D</i> = 69</span>) was published in 1994.<sup id="cite_ref-Clark_1994_161-1" class="reference"><a href="#cite_note-Clark_1994-161"><span class="cite-bracket">[</span>159<span class="cite-bracket">]</span></a></sup> In 1973, Weinberger proved that a quadratic integer ring with <span class="texhtml"><i>D</i> &gt; 0</span> is Euclidean if, and only if, it is a <a href="Principal_ideal_domain" title="Principal ideal domain">principal ideal domain</a>, provided that the <a href="Generalized_Riemann_hypothesis" title="Generalized Riemann hypothesis">generalized Riemann hypothesis</a> holds.<sup id="cite_ref-weinberger_131-1" class="reference"><a href="#cite_note-weinberger-131"><span class="cite-bracket">[</span>130<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Noncommutative_rings">Noncommutative rings</h3></div>
<p>The Euclidean algorithm may be applied to some noncommutative rings such as the set of <a href="Hurwitz_quaternion" title="Hurwitz quaternion">Hurwitz quaternions</a>.<sup id="cite_ref-stillwell151-152_132-1" class="reference"><a href="#cite_note-stillwell151-152-132"><span class="cite-bracket">[</span>131<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-bgv_162-0" class="reference"><a href="#cite_note-bgv-162"><span class="cite-bracket">[</span>160<span class="cite-bracket">]</span></a></sup> Let <span class="texhtml mvar" style="font-style:italic;">α</span> and <span class="texhtml mvar" style="font-style:italic;">β</span> represent two elements from such a ring. They have a common right divisor <span class="texhtml mvar" style="font-style:italic;">δ</span> if <span class="texhtml"><i>α</i> = <i>ξδ</i></span> and <span class="texhtml"><i>β</i> = <i>ηδ</i></span> for some choice of <span class="texhtml mvar" style="font-style:italic;">ξ</span> and <span class="texhtml mvar" style="font-style:italic;">η</span> in the ring. Similarly, they have a common left divisor if <span class="texhtml"><i>α</i> = <i>dξ</i></span> and <span class="texhtml"><i>β</i> = <i>dη</i></span> for some choice of <span class="texhtml mvar" style="font-style:italic;">ξ</span> and <span class="texhtml mvar" style="font-style:italic;">η</span> in the ring. Since multiplication is not commutative, there are two versions of the Euclidean algorithm, one for right divisors and one for left divisors.<sup id="cite_ref-stillwell151-152_132-2" class="reference"><a href="#cite_note-stillwell151-152-132"><span class="cite-bracket">[</span>131<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-bgv_162-1" class="reference"><a href="#cite_note-bgv-162"><span class="cite-bracket">[</span>160<span class="cite-bracket">]</span></a></sup> Choosing the right divisors, the first step in finding the <span class="texhtml">gcd(<i>α</i>, <i>β</i>)</span> by the Euclidean algorithm can be written
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \rho _{0}=\alpha -\psi _{0}\beta =(\xi -\psi _{0}\eta )\delta ,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>ρ<!-- ρ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>α<!-- α --></mi>
<mo>−<!-- − --></mo>
<msub>
<mi>ψ<!-- ψ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mi>β<!-- β --></mi>
<mo>=</mo>
<mo stretchy="false">(</mo>
<mi>ξ<!-- ξ --></mi>
<mo>−<!-- − --></mo>
<msub>
<mi>ψ<!-- ψ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mi>η<!-- η --></mi>
<mo stretchy="false">)</mo>
<mi>δ<!-- δ --></mi>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \rho _{0}=\alpha -\psi _{0}\beta =(\xi -\psi _{0}\eta )\delta ,}</annotation>
</semantics>
</math></span><img src="./4cbc45d7a01f23c3fa9b97f5d6ca1d20a4639e03.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:27.793ex; height:2.843ex;" alt="{\displaystyle \rho _{0}=\alpha -\psi _{0}\beta =(\xi -\psi _{0}\eta )\delta ,}" loading="lazy"></span></dd></dl>
<p>where <span class="texhtml"><i>ψ</i><sub>0</sub></span> represents the quotient and <span class="texhtml"><i>ρ</i><sub>0</sub></span> the remainder. Here the quotient and remainder are chosen so that (if nonzero) the remainder has <span class="texhtml"><i>N</i>(<i>ρ</i><sub>0</sub>) &lt; <i>N</i>(<i>β</i>)</span> for a "Euclidean function" <i>N</i> defined analogously to the Euclidean functions of <a href="Euclidean_domain" title="Euclidean domain">Euclidean domains</a> in the non-commutative case.<sup id="cite_ref-bgv_162-2" class="reference"><a href="#cite_note-bgv-162"><span class="cite-bracket">[</span>160<span class="cite-bracket">]</span></a></sup> This equation shows that any common right divisor of <span class="texhtml mvar" style="font-style:italic;">α</span> and <span class="texhtml mvar" style="font-style:italic;">β</span> is likewise a common divisor of the remainder <span class="texhtml"><i>ρ</i><sub>0</sub></span>. The analogous equation for the left divisors would be
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \rho _{0}=\alpha -\beta \psi _{0}=\delta (\xi -\eta \psi _{0}).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>ρ<!-- ρ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>α<!-- α --></mi>
<mo>−<!-- − --></mo>
<mi>β<!-- β --></mi>
<msub>
<mi>ψ<!-- ψ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>=</mo>
<mi>δ<!-- δ --></mi>
<mo stretchy="false">(</mo>
<mi>ξ<!-- ξ --></mi>
<mo>−<!-- − --></mo>
<mi>η<!-- η --></mi>
<msub>
<mi>ψ<!-- ψ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \rho _{0}=\alpha -\beta \psi _{0}=\delta (\xi -\eta \psi _{0}).}</annotation>
</semantics>
</math></span><img src="./c98ce45a2ec2ce08f12fba65e4c79ac36d0c4ac1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:27.793ex; height:2.843ex;" alt="{\displaystyle \rho _{0}=\alpha -\beta \psi _{0}=\delta (\xi -\eta \psi _{0}).}" loading="lazy"></span></dd></dl>
<p>With either choice, the process is repeated as above until the greatest common right or left divisor is identified. As in the Euclidean domain, the "size" of the remainder <span class="texhtml"><i>ρ</i><sub>0</sub></span> (formally, its Euclidean function or "norm") must be strictly smaller than <span class="texhtml mvar" style="font-style:italic;">β</span>, and there must be only a finite number of possible sizes for <span class="texhtml"><i>ρ</i><sub>0</sub></span>, so that the algorithm is guaranteed to terminate.<sup id="cite_ref-entgtrg_163-0" class="reference"><a href="#cite_note-entgtrg-163"><span class="cite-bracket">[</span>161<span class="cite-bracket">]</span></a></sup>
</p><p>Many results for the GCD carry over to noncommutative numbers. For example, <a href="B%C3%A9zout's_identity" title="Bézout's identity">Bézout's identity</a> states that the right <span class="texhtml">gcd(<i>α</i>, <i>β</i>)</span> can be expressed as a linear combination of <span class="texhtml mvar" style="font-style:italic;">α</span> and <span class="texhtml mvar" style="font-style:italic;">β</span>.<sup id="cite_ref-164" class="reference"><a href="#cite_note-164"><span class="cite-bracket">[</span>162<span class="cite-bracket">]</span></a></sup> In other words, there are numbers <span class="texhtml mvar" style="font-style:italic;">σ</span> and <span class="texhtml mvar" style="font-style:italic;">τ</span> such that
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Gamma _{\text{right}}=\sigma \alpha +\tau \beta .}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi mathvariant="normal">Γ<!-- Γ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mtext>right</mtext>
</mrow>
</msub>
<mo>=</mo>
<mi>σ<!-- σ --></mi>
<mi>α<!-- α --></mi>
<mo>+</mo>
<mi>τ<!-- τ --></mi>
<mi>β<!-- β --></mi>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Gamma _{\text{right}}=\sigma \alpha +\tau \beta .}</annotation>
</semantics>
</math></span><img src="./aa8d8d3f8987285f9825f8a95255112612f8239f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:17.1ex; height:2.843ex;" alt="{\displaystyle \Gamma _{\text{right}}=\sigma \alpha +\tau \beta .}" loading="lazy"></span></dd></dl>
<p>The analogous identity for the left GCD is nearly the same:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Gamma _{\text{left}}=\alpha \sigma +\beta \tau .}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi mathvariant="normal">Γ<!-- Γ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mtext>left</mtext>
</mrow>
</msub>
<mo>=</mo>
<mi>α<!-- α --></mi>
<mi>σ<!-- σ --></mi>
<mo>+</mo>
<mi>β<!-- β --></mi>
<mi>τ<!-- τ --></mi>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Gamma _{\text{left}}=\alpha \sigma +\beta \tau .}</annotation>
</semantics>
</math></span><img src="./7c007a58c690dcbd89cd48db55ed36d92fa9b6e8.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:15.952ex; height:2.509ex;" alt="{\displaystyle \Gamma _{\text{left}}=\alpha \sigma +\beta \tau .}" loading="lazy"></span></dd></dl>
<p>Bézout's identity can be used to solve Diophantine equations. For instance, one of the standard proofs of <a href="Lagrange's_four-square_theorem" title="Lagrange's four-square theorem">Lagrange's four-square theorem</a>, that every positive integer can be represented as a sum of four squares, is based on quaternion GCDs in this way.<sup id="cite_ref-entgtrg_163-1" class="reference"><a href="#cite_note-entgtrg-163"><span class="cite-bracket">[</span>161<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */


.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */


@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}


/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist"><a href="Wikifunctions" title="Wikifunctions">Wikifunctions</a> has <b><a href="https://www.wikifunctions.org/wiki/Z13639" class="extiw external" title="f:Z13639">a Euclidean algorithm function</a></b>.</div></div>
</div>
<ul><li><a href="Euclidean_rhythm" title="Euclidean rhythm">Euclidean rhythm</a>, a method for using the Euclidean algorithm to generate musical rhythms</li></ul>
<div style="clear:both;" class=""></div>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Some widely used textbooks, such as <a href="I._N._Herstein" class="mw-redirect" title="I. N. Herstein">I. N. Herstein</a>'s <i>Topics in Algebra</i> and <a href="Serge_Lang" title="Serge Lang">Serge Lang</a>'s <i>Algebra</i>, use the term "Euclidean algorithm" to refer to <a href="Euclidean_division" title="Euclidean division">Euclidean division</a></span>
</li>
<li id="cite_note-143"><span class="mw-cite-backlink"><b><a href="#cite_ref-143">^</a></b></span> <span class="reference-text">The phrase "ordinary integer" is commonly used for distinguishing usual integers from Gaussian integers, and more generally from <a href="Algebraic_integer" title="Algebraic integer">algebraic integers</a>.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="reflist reflist-columns references-column-width" style="column-width: 30em;">
<ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFLamé1844" class="citation journal cs1 cs1-prop-foreign-lang-source">Lamé, Gabriel (1844). "Note sur la limite du nombre des divisions dans la recherche du plus grand commun diviseur entre deux nombres entiers". <i>Comptes Rendus des Séances de l'Académie des Sciences</i> (in French). <b>19</b>: <span class="nowrap">867–</span>870.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFShallit1994" class="citation journal cs1">Shallit, Jeffrey (1994-11-01). <a rel="nofollow" class="external text" href="https://doi.org/10.1006%2Fhmat.1994.1031">"Origins of the analysis of the Euclidean algorithm"</a>. <i>Historia Mathematica</i>. <b>21</b> (4): <span class="nowrap">401–</span>419. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1006%2Fhmat.1994.1031">10.1006/hmat.1994.1031</a></span>. <a href="ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a>&nbsp;<a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/0315-0860">0315-0860</a>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;16</span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;21</span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><a href="#CITEREFLeVeque1996">LeVeque 1996</a>, p.&nbsp;32</span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><a href="#CITEREFLeVeque1996">LeVeque 1996</a>, p.&nbsp;31</span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFGrossman1990" class="citation book cs1">Grossman, J. W. (1990). <i>Discrete Mathematics</i>. New York: Macmillan. p.&nbsp;213. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-02-348331-8</bdi>.</cite></span>
</li>
<li id="cite_note-Schroeder_21-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-Schroeder_21_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Schroeder_21_9-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;21–22</span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, p.&nbsp;19</span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite id="CITEREFOgilvyAnderson1966" class="citation book cs1"><a href="C._Stanley_Ogilvy" title="C. Stanley Ogilvy">Ogilvy, C. S.</a>; Anderson, J. T. (1966). <i>Excursions in number theory</i>. New York: <a href="Oxford_University_Press" title="Oxford University Press">Oxford University Press</a>. pp.&nbsp;<span class="nowrap">27–</span>29.</cite></span>
</li>
<li id="cite_note-Schroeder_216-12"><span class="mw-cite-backlink">^ <a href="#cite_ref-Schroeder_216_12-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Schroeder_216_12-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;216–219</span>
</li>
<li id="cite_note-Leveque_p33-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-Leveque_p33_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Leveque_p33_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFLeVeque1996">LeVeque 1996</a>, p.&nbsp;33</span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;25</span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><a href="#CITEREFOre1948">Ore 1948</a>, pp.&nbsp;47–48</span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;18</span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, pp.&nbsp;16–20</span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p.&nbsp;320</span>
</li>
<li id="cite_note-Lovasz_2003-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-Lovasz_2003_19-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFLovászPelikánVesztergombi2003" class="citation book cs1"><a href="L%C3%A1szl%C3%B3_Lov%C3%A1sz" title="László Lovász">Lovász, L.</a>; Pelikán, J.; <a href="Katalin_Vesztergombi" title="Katalin Vesztergombi">Vesztergombi, K.</a> (2003). <i>Discrete Mathematics: Elementary and Beyond</i>. New York: Springer-Verlag. pp.&nbsp;<span class="nowrap">100–</span>101. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-95584-4</bdi>.</cite></span>
</li>
<li id="cite_note-Kimberling_1983-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Kimberling_1983_20-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFKimberling1983" class="citation journal cs1"><a href="Clark_Kimberling" title="Clark Kimberling">Kimberling, C.</a> (1983). "A Visual Euclidean Algorithm". <i>Mathematics Teacher</i>. <b>76</b>: <span class="nowrap">108–</span>109.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite id="CITEREFDummitFoote2004" class="citation book cs1">Dummit, David S.; Foote, Richard M. (2004). <i>Abstract Algebra</i>. John Wiley &amp; Sons, Inc. pp.&nbsp;<span class="nowrap">270–</span>271. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-471-43334-7</bdi>.</cite></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp.&nbsp;319–320</span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp.&nbsp;318–319</span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><a href="#CITEREFStillwell1997">Stillwell 1997</a>, p.&nbsp;14</span>
</li>
<li id="cite_note-Ore_least_abs_remainders-25"><span class="mw-cite-backlink">^ <a href="#cite_ref-Ore_least_abs_remainders_25-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Ore_least_abs_remainders_25-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFOre1948">Ore 1948</a>, p.&nbsp;43</span>
</li>
<li id="cite_note-Stewart_1964-26"><span class="mw-cite-backlink">^ <a href="#cite_ref-Stewart_1964_26-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Stewart_1964_26-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFStewart1964" class="citation book cs1">Stewart, B. M. (1964). <i>Theory of Numbers</i> (2nd&nbsp;ed.). New York: Macmillan. pp.&nbsp;<span class="nowrap">43–</span>44. <a href="LCCN_(identifier)" class="mw-redirect" title="LCCN (identifier)">LCCN</a>&nbsp;<a rel="nofollow" class="external text" href="https://lccn.loc.gov/64010964">64010964</a>.</cite></span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><cite id="CITEREFLazard1977" class="citation journal cs1 cs1-prop-foreign-lang-source">Lazard, D. (1977). "Le meilleur algorithme d'Euclide pour <i>K</i>[<i>X</i>] et <b>Z</b>". <i>Comptes Rendus de l'Académie des Sciences</i> (in French). <b>284</b>: <span class="nowrap">1–</span>4.</cite></span>
</li>
<li id="cite_note-Knuth,_p._318-28"><span class="mw-cite-backlink">^ <a href="#cite_ref-Knuth,_p._318_28-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Knuth,_p._318_28-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 318</span>
</li>
<li id="cite_note-Weil_1983-29"><span class="mw-cite-backlink">^ <a href="#cite_ref-Weil_1983_29-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Weil_1983_29-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFWeil1983" class="citation book cs1"><a href="Andr%C3%A9_Weil" title="André Weil">Weil, A.</a> (1983). <i>Number Theory</i>. Boston: Birkhäuser. pp.&nbsp;<span class="nowrap">4–</span>6. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-8176-3141-0</bdi>.</cite></span>
</li>
<li id="cite_note-Jones_1994-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-Jones_1994_30-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFJones1994" class="citation book cs1">Jones, A. (1994). "Greek mathematics to AD 300". <i>Companion encyclopedia of the history and philosophy of the mathematical sciences</i>. New York: Routledge. pp.&nbsp;<span class="nowrap">46–</span>48. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-415-09238-8</bdi>.</cite></span>
</li>
<li id="cite_note-van_der_Waerden_1954-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-van_der_Waerden_1954_31-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFvan_der_Waerden1954" class="citation book cs1"><a href="Bartel_Leendert_van_der_Waerden" title="Bartel Leendert van der Waerden">van der Waerden, B. L.</a> (1954). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/scienceawakening00waer"><i>Science Awakening</i></a></span>. translated by Arnold Dresden. Groningen: P. Noordhoff Ltd. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/scienceawakening00waer/page/114">114–115</a>.</cite></span>
</li>
<li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><cite id="CITEREFvon_Fritz1945" class="citation journal cs1">von Fritz, K. (1945). "The Discovery of Incommensurability by Hippasus of Metapontum". <i>Annals of Mathematics</i>. <b>46</b> (2): <span class="nowrap">242–</span>264. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F1969021">10.2307/1969021</a>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/1969021">1969021</a>.</cite></span>
</li>
<li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text"><cite id="CITEREFHeath1949" class="citation book cs1"><a href="T._L._Heath" class="mw-redirect" title="T. L. Heath">Heath, T. L.</a> (1949). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/mathematicsinari0000heat"><i>Mathematics in Aristotle</i></a></span>. Oxford Press. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/mathematicsinari0000heat/page/80">80–83</a>.</cite></span>
</li>
<li id="cite_note-34"><span class="mw-cite-backlink"><b><a href="#cite_ref-34">^</a></b></span> <span class="reference-text"><cite id="CITEREFFowler1987" class="citation book cs1"><a href="David_Fowler_(mathematician)" title="David Fowler (mathematician)">Fowler, D. H.</a> (1987). <i>The Mathematics of Plato's Academy: A New Reconstruction</i>. Oxford: Oxford University Press. pp.&nbsp;<span class="nowrap">31–</span>66. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-19-853912-6</bdi>.</cite></span>
</li>
<li id="cite_note-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-35">^</a></b></span> <span class="reference-text"><cite id="CITEREFBecker1933" class="citation journal cs1">Becker, O. (1933). "Eudoxus-Studien I. Eine voreuklidische Proportionslehre und ihre Spuren bei Aristoteles und Euklid". <i>Quellen und Studien zur Geschichte der Mathematik B</i>. <b>2</b>: <span class="nowrap">311–</span>333.</cite></span>
</li>
<li id="cite_note-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-36">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrezinski1991" class="citation book cs1">Brezinski, Claude (1991). <i>History of continued fractions and Padé approximants</i>. Springer Series in Computational Mathematics. Vol.&nbsp;12. Springer-Verlag, Berlin. p.&nbsp;<a rel="nofollow" class="external text" href="https://books.google.com/books?id=rxzsCAAAQBAJ&amp;pg=PA6">6</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-642-58169-4">10.1007/978-3-642-58169-4</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>3-540-15286-5</bdi>. <a href="MR_(identifier)" class="mw-redirect" title="MR (identifier)">MR</a>&nbsp;<a rel="nofollow" class="external text" href="https://mathscinet.ams.org/mathscinet-getitem?mr=1083352">1083352</a>.</cite></span>
</li>
<li id="cite_note-Stillwell,_p._31-37"><span class="mw-cite-backlink">^ <a href="#cite_ref-Stillwell,_p._31_37-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Stillwell,_p._31_37-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFStillwell1997">Stillwell 1997</a>, p.&nbsp;31</span>
</li>
<li id="cite_note-Tattersall,_p._70-38"><span class="mw-cite-backlink">^ <a href="#cite_ref-Tattersall,_p._70_38-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Tattersall,_p._70_38-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFTattersall2005">Tattersall 2005</a>, p.&nbsp;70</span>
</li>
<li id="cite_note-39"><span class="mw-cite-backlink"><b><a href="#cite_ref-39">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, pp.&nbsp;86–87</span>
</li>
<li id="cite_note-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-40">^</a></b></span> <span class="reference-text"><a href="#CITEREFOre1948">Ore 1948</a>, pp.&nbsp;247–248</span>
</li>
<li id="cite_note-41"><span class="mw-cite-backlink"><b><a href="#cite_ref-41">^</a></b></span> <span class="reference-text"><a href="#CITEREFTattersall2005">Tattersall 2005</a>, pp.&nbsp;72, 184–185</span>
</li>
<li id="cite_note-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-42">^</a></b></span> <span class="reference-text"><cite id="CITEREFSaunderson1740" class="citation book cs1">Saunderson, Nicholas (1740). <a rel="nofollow" class="external text" href="http://www.e-rara.ch/zut/content/structure/2440626"><i>The Elements of Algebra in Ten Books</i></a>. University of Cambridge Press<span class="reference-accessdate">. Retrieved <span class="nowrap">1 November</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-43"><span class="mw-cite-backlink"><b><a href="#cite_ref-43">^</a></b></span> <span class="reference-text"><a href="#CITEREFTattersall2005">Tattersall 2005</a>, pp.&nbsp;72–76</span>
</li>
<li id="cite_note-Gauss_1832-44"><span class="mw-cite-backlink">^ <a href="#cite_ref-Gauss_1832_44-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Gauss_1832_44-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFGauss1832" class="citation journal cs1"><a href="Carl_Friedrich_Gauss" title="Carl Friedrich Gauss">Gauss, C. F.</a> (1832). "Theoria residuorum biquadraticorum". <i>Comm. Soc. Reg. Sci. Gött. Rec</i>. <b>4</b>.</cite> Reprinted in <cite id="CITEREFGauss2011" class="citation book cs1">Gauss, C. F. (2011). "Theoria residuorum biquadraticorum commentatio prima". <i>Werke</i>. Vol.&nbsp;2. Cambridge Univ. Press. pp.&nbsp;<span class="nowrap">65–</span>92. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FCBO9781139058230.004">10.1017/CBO9781139058230.004</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781139058230</bdi>.</cite> and <cite id="CITEREFGauss2011" class="citation book cs1">Gauss, C. F. (2011). "Theoria residuorum biquadraticorum commentatio secunda". <i>Werke</i>. Vol.&nbsp;2. Cambridge Univ. Press. pp.&nbsp;<span class="nowrap">93–</span>148. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FCBO9781139058230.005">10.1017/CBO9781139058230.005</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781139058230</bdi>.</cite></span>
</li>
<li id="cite_note-45"><span class="mw-cite-backlink"><b><a href="#cite_ref-45">^</a></b></span> <span class="reference-text"><a href="#CITEREFStillwell1997">Stillwell 1997</a>, pp.&nbsp;31–32</span>
</li>
<li id="cite_note-46"><span class="mw-cite-backlink"><b><a href="#cite_ref-46">^</a></b></span> <span class="reference-text"><a href="#CITEREFLejeune_Dirichlet1894">Lejeune Dirichlet 1894</a>, pp.&nbsp;29–31</span>
</li>
<li id="cite_note-47"><span class="mw-cite-backlink"><b><a href="#cite_ref-47">^</a></b></span> <span class="reference-text"><a href="Richard_Dedekind" title="Richard Dedekind">Richard Dedekind</a> in <a href="#CITEREFLejeune_Dirichlet1894">Lejeune Dirichlet 1894</a>, Supplement XI</span>
</li>
<li id="cite_note-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-48">^</a></b></span> <span class="reference-text"><a href="#CITEREFStillwell2003">Stillwell 2003</a>, pp.&nbsp;41–42</span>
</li>
<li id="cite_note-49"><span class="mw-cite-backlink"><b><a href="#cite_ref-49">^</a></b></span> <span class="reference-text"><cite id="CITEREFSturm1829" class="citation journal cs1 cs1-prop-foreign-lang-source"><a href="Jacques_Charles_Fran%C3%A7ois_Sturm" title="Jacques Charles François Sturm">Sturm, C.</a> (1829). "Mémoire sur la résolution des équations numériques". <i>Bull. Des sciences de Férussac</i> (in French). <b>11</b>: <span class="nowrap">419–</span>422.</cite></span>
</li>
<li id="cite_note-50"><span class="mw-cite-backlink"><b><a href="#cite_ref-50">^</a></b></span> <span class="reference-text">
<cite id="CITEREFFergusonForcade1979" class="citation journal cs1"><a href="Helaman_Ferguson" title="Helaman Ferguson">Ferguson, H. R. P.</a>; Forcade, R. W. (1979). <a rel="nofollow" class="external text" href="https://doi.org/10.1090%2FS0273-0979-1979-14691-3">"Generalization of the Euclidean algorithm for real numbers to all dimensions higher than two"</a>. <i>Bulletin of the American Mathematical Society</i>. New Series. <b>1</b> (6): <span class="nowrap">912–</span>914. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1090%2FS0273-0979-1979-14691-3">10.1090/S0273-0979-1979-14691-3</a></span>. <a href="MR_(identifier)" class="mw-redirect" title="MR (identifier)">MR</a>&nbsp;<a rel="nofollow" class="external text" href="https://mathscinet.ams.org/mathscinet-getitem?mr=0546316">0546316</a>.</cite></span>
</li>
<li id="cite_note-51"><span class="mw-cite-backlink"><b><a href="#cite_ref-51">^</a></b></span> <span class="reference-text"><cite id="CITEREFPeterson2002" class="citation journal cs1">Peterson, I. (12 August 2002). <a rel="nofollow" class="external text" href="http://www.sciencenews.org/view/generic/id/172/title/Math_Trek__Jazzing_Up_Euclids_Algorithm">"Jazzing Up Euclid's Algorithm"</a>. <i>ScienceNews</i>.</cite></span>
</li>
<li id="cite_note-52"><span class="mw-cite-backlink"><b><a href="#cite_ref-52">^</a></b></span> <span class="reference-text"><cite id="CITEREFCipra2000" class="citation journal cs1"><a href="Barry_Arthur_Cipra" title="Barry Arthur Cipra">Cipra, Barry Arthur</a> (16 May 2000). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160922144038/https://www.siam.org/pdf/news/637.pdf">"The Best of the 20th Century: Editors Name Top 10 Algorithms"</a> <span class="cs1-format">(PDF)</span>. <i>SIAM News</i>. <b>33</b> (4). <a href="Society_for_Industrial_and_Applied_Mathematics" title="Society for Industrial and Applied Mathematics">Society for Industrial and Applied Mathematics</a>. Archived from <a rel="nofollow" class="external text" href="https://www.siam.org/pdf/news/637.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 22 September 2016<span class="reference-accessdate">. Retrieved <span class="nowrap">19 July</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-53"><span class="mw-cite-backlink"><b><a href="#cite_ref-53">^</a></b></span> <span class="reference-text"><cite id="CITEREFColeDavie1969" class="citation journal cs1">Cole, A. J.; Davie, A. J. T. (1969). "A game based on the Euclidean algorithm and a winning strategy for it". <i>Math. Gaz</i>. <b>53</b> (386): <span class="nowrap">354–</span>357. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F3612461">10.2307/3612461</a>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/3612461">3612461</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:125164797">125164797</a>.</cite></span>
</li>
<li id="cite_note-54"><span class="mw-cite-backlink"><b><a href="#cite_ref-54">^</a></b></span> <span class="reference-text"><cite id="CITEREFSpitznagel1973" class="citation journal cs1">Spitznagel, E. L. (1973). "Properties of a game based on Euclid's algorithm". <i>Math. Mag</i>. <b>46</b> (2): <span class="nowrap">87–</span>92. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2689037">10.2307/2689037</a>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2689037">2689037</a>.</cite></span>
</li>
<li id="cite_note-55"><span class="mw-cite-backlink"><b><a href="#cite_ref-55">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, p.&nbsp;95</span>
</li>
<li id="cite_note-56"><span class="mw-cite-backlink"><b><a href="#cite_ref-56">^</a></b></span> <span class="reference-text"><cite id="CITEREFRoberts1977" class="citation book cs1">Roberts, J. (1977). <a rel="nofollow" class="external text" href="https://archive.org/details/Elementary_00_Robe/page/1"><i>Elementary Number Theory: A Problem Oriented Approach</i></a>. Cambridge, MA: <a href="MIT_Press" title="MIT Press">MIT Press</a>. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/Elementary_00_Robe/page/1">1–8</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-262-68028-9</bdi>.</cite></span>
</li>
<li id="cite_note-57"><span class="mw-cite-backlink"><b><a href="#cite_ref-57">^</a></b></span> <span class="reference-text"><cite id="CITEREFJonesJones1998" class="citation book cs1">Jones, G. A.; Jones, J. M. (1998). "Bezout's Identity". <i>Elementary Number Theory</i>. New York: Springer-Verlag. pp.&nbsp;<span class="nowrap">7–</span>11.</cite></span>
</li>
<li id="cite_note-58"><span class="mw-cite-backlink"><b><a href="#cite_ref-58">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, p.&nbsp;81</span>
</li>
<li id="cite_note-59"><span class="mw-cite-backlink"><b><a href="#cite_ref-59">^</a></b></span> <span class="reference-text"><a href="#CITEREFCohn1980">Cohn 1980</a>, p.&nbsp;104</span>
</li>
<li id="cite_note-60"><span class="mw-cite-backlink"><b><a href="#cite_ref-60">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, p.&nbsp;91</span>
</li>
<li id="cite_note-61"><span class="mw-cite-backlink"><b><a href="#cite_ref-61">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, p.&nbsp;23</span>
</li>
<li id="cite_note-62"><span class="mw-cite-backlink"><b><a href="#cite_ref-62">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, pp.&nbsp;90–93</span>
</li>
<li id="cite_note-Koshy_2002-63"><span class="mw-cite-backlink">^ <a href="#cite_ref-Koshy_2002_63-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Koshy_2002_63-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFKoshy2002" class="citation book cs1">Koshy, T. (2002). <i>Elementary Number Theory with Applications</i>. Burlington, MA: Harcourt/Academic Press. pp.&nbsp;<span class="nowrap">167–</span>169. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-12-421171-2</bdi>.</cite></span>
</li>
<li id="cite_note-Bach_1996-64"><span class="mw-cite-backlink"><b><a href="#cite_ref-Bach_1996_64-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFBachShallit1996" class="citation book cs1"><a href="Eric_Bach" title="Eric Bach">Bach, E.</a>; <a href="Jeffrey_Shallit" title="Jeffrey Shallit">Shallit, J.</a> (1996). <i>Algorithmic number theory</i>. Cambridge, MA: MIT Press. pp.&nbsp;<span class="nowrap">70–</span>73. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-262-02405-5</bdi>.</cite></span>
</li>
<li id="cite_note-65"><span class="mw-cite-backlink"><b><a href="#cite_ref-65">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, pp.&nbsp;26–36</span>
</li>
<li id="cite_note-Ore,_p._44-66"><span class="mw-cite-backlink">^ <a href="#cite_ref-Ore,_p._44_66-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Ore,_p._44_66-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFOre1948">Ore 1948</a>, p.&nbsp;44</span>
</li>
<li id="cite_note-67"><span class="mw-cite-backlink"><b><a href="#cite_ref-67">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, pp.&nbsp;281–292</span>
</li>
<li id="cite_note-68"><span class="mw-cite-backlink"><b><a href="#cite_ref-68">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, pp.&nbsp;119–125</span>
</li>
<li id="cite_note-69"><span class="mw-cite-backlink"><b><a href="#cite_ref-69">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;106–107</span>
</li>
<li id="cite_note-70"><span class="mw-cite-backlink"><b><a href="#cite_ref-70">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;108–109</span>
</li>
<li id="cite_note-71"><span class="mw-cite-backlink"><b><a href="#cite_ref-71">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, pp.&nbsp;120–121</span>
</li>
<li id="cite_note-72"><span class="mw-cite-backlink"><b><a href="#cite_ref-72">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;47</span>
</li>
<li id="cite_note-73"><span class="mw-cite-backlink"><b><a href="#cite_ref-73">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;107–109</span>
</li>
<li id="cite_note-74"><span class="mw-cite-backlink"><b><a href="#cite_ref-74">^</a></b></span> <span class="reference-text"><a href="#CITEREFStillwell1997">Stillwell 1997</a>, pp.&nbsp;186–187</span>
</li>
<li id="cite_note-75"><span class="mw-cite-backlink"><b><a href="#cite_ref-75">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, p.&nbsp;134</span>
</li>
<li id="cite_note-76"><span class="mw-cite-backlink"><b><a href="#cite_ref-76">^</a></b></span> <span class="reference-text"><cite id="CITEREFMoon2005" class="citation book cs1">Moon, T. K. (2005). <i>Error Correction Coding: Mathematical Methods and Algorithms</i>. John Wiley and Sons. p.&nbsp;266. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-471-64800-0</bdi>.</cite></span>
</li>
<li id="cite_note-77"><span class="mw-cite-backlink"><b><a href="#cite_ref-77">^</a></b></span> <span class="reference-text"><a href="#CITEREFRosen2000">Rosen 2000</a>, pp.&nbsp;143–170</span>
</li>
<li id="cite_note-78"><span class="mw-cite-backlink"><b><a href="#cite_ref-78">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;194–195</span>
</li>
<li id="cite_note-79"><span class="mw-cite-backlink"><b><a href="#cite_ref-79">^</a></b></span> <span class="reference-text"><cite id="CITEREFGrahamKnuthPatashnik1989" class="citation book cs1"><a href="Ronald_Graham" title="Ronald Graham">Graham, R.</a>; <a href="Donald_Knuth" title="Donald Knuth">Knuth, D. E.</a>; <a href="Oren_Patashnik" title="Oren Patashnik">Patashnik, O.</a> (1989). <i>Concrete mathematics</i>. Addison-Wesley. p.&nbsp;123.</cite></span>
</li>
<li id="cite_note-Vinogradov_1954-80"><span class="mw-cite-backlink"><b><a href="#cite_ref-Vinogradov_1954_80-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFVinogradov1954" class="citation book cs1"><a href="Ivan_Matveyevich_Vinogradov" class="mw-redirect" title="Ivan Matveyevich Vinogradov">Vinogradov, I. M.</a> (1954). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/elementsofnumber0000vino"><i>Elements of Number Theory</i></a></span>. New York: Dover. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/elementsofnumber0000vino/page/3">3–13</a>.</cite></span>
</li>
<li id="cite_note-81"><span class="mw-cite-backlink"><b><a href="#cite_ref-81">^</a></b></span> <span class="reference-text"><a href="#CITEREFCrandallPomerance2001">Crandall &amp; Pomerance 2001</a>, pp. 225–349</span>
</li>
<li id="cite_note-82"><span class="mw-cite-backlink"><b><a href="#cite_ref-82">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp. 369–371</span>
</li>
<li id="cite_note-83"><span class="mw-cite-backlink"><b><a href="#cite_ref-83">^</a></b></span> <span class="reference-text"><cite id="CITEREFShor1997" class="citation journal cs1"><a href="Peter_Shor" title="Peter Shor">Shor, P. W.</a> (1997). "Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer". <i>SIAM Journal on Scientific and Statistical Computing</i>. <b>26</b> (5): <span class="nowrap">1484–</span>1509. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/quant-ph/9508027">quant-ph/9508027</a></span>. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/1995quant.ph..8027S">1995quant.ph..8027S</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2Fs0097539795293172">10.1137/s0097539795293172</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:2337707">2337707</a>.</cite></span>
</li>
<li id="cite_note-84"><span class="mw-cite-backlink"><b><a href="#cite_ref-84">^</a></b></span> <span class="reference-text"><cite id="CITEREFDixon1981" class="citation journal cs1">Dixon, J. D. (1981). <a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2007743">"Asymptotically fast factorization of integers"</a>. <i>Math. Comput</i>. <b>36</b> (153): <span class="nowrap">255–</span>260. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2007743">10.2307/2007743</a></span>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2007743">2007743</a>.</cite></span>
</li>
<li id="cite_note-85"><span class="mw-cite-backlink"><b><a href="#cite_ref-85">^</a></b></span> <span class="reference-text"><cite id="CITEREFLenstra1987" class="citation journal cs1"><a href="Hendrik_Lenstra" title="Hendrik Lenstra">Lenstra, H. W. Jr.</a> (1987). "Factoring integers with elliptic curves". <i>Annals of Mathematics</i>. <b>126</b> (3): <span class="nowrap">649–</span>673. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F1971363">10.2307/1971363</a>. <a href="Hdl_(identifier)" class="mw-redirect" title="Hdl (identifier)">hdl</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://hdl.handle.net/1887%2F2140">1887/2140</a></span>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/1971363">1971363</a>.</cite></span>
</li>
<li id="cite_note-86"><span class="mw-cite-backlink"><b><a href="#cite_ref-86">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp. 380–384</span>
</li>
<li id="cite_note-87"><span class="mw-cite-backlink"><b><a href="#cite_ref-87">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp. 339–364</span>
</li>
<li id="cite_note-88"><span class="mw-cite-backlink"><b><a href="#cite_ref-88">^</a></b></span> <span class="reference-text"><cite id="CITEREFReynaud1811" class="citation book cs1">Reynaud, A.-A.-L. (1811). <a rel="nofollow" class="external text" href="https://archive.org/details/bub_gb_YySjvK7oudIC"><i>Traité d'arithmétique à l'usage des élèves qui se destinent à l'École Polytechnique</i></a> (6th&nbsp;ed.). Paris: Courcier. Note 60, p.&nbsp;34.</cite> As cited by <a href="#CITEREFShallit1994">Shallit (1994)</a>.</span>
</li>
<li id="cite_note-89"><span class="mw-cite-backlink"><b><a href="#cite_ref-89">^</a></b></span> <span class="reference-text"><cite id="CITEREFFinck1841" class="citation book cs1 cs1-prop-foreign-lang-source">Finck, P.-J.-E. (1841). <i>Traité élémentaire d'arithmétique à l'usage des candidats aux écoles spéciales</i> (in French). Derivaux.</cite></span>
</li>
<li id="cite_note-FOOTNOTEShallit1994-90"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEShallit1994_90-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEShallit1994_90-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFShallit1994">Shallit 1994</a>.</span>
</li>
<li id="cite_note-91"><span class="mw-cite-backlink"><b><a href="#cite_ref-91">^</a></b></span> <span class="reference-text"><cite id="CITEREFLamé1844" class="citation journal cs1 cs1-prop-foreign-lang-source"><a href="Gabriel_Lam%C3%A9" title="Gabriel Lamé">Lamé, G.</a> (1844). "Note sur la limite du nombre des divisions dans la recherche du plus grand commun diviseur entre deux nombres entiers". <i>Comptes Rendus de l'Académie des Sciences</i> (in French). <b>19</b>: <span class="nowrap">867–</span>870.</cite></span>
</li>
<li id="cite_note-92"><span class="mw-cite-backlink"><b><a href="#cite_ref-92">^</a></b></span> <span class="reference-text"><cite id="CITEREFGrossman1924" class="citation journal cs1">Grossman, H. (1924). "On the Number of Divisions in Finding a G.C.D". <i>The American Mathematical Monthly</i>. <b>31</b> (9): 443. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2298146">10.2307/2298146</a>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2298146">2298146</a>.</cite></span>
</li>
<li id="cite_note-93"><span class="mw-cite-backlink"><b><a href="#cite_ref-93">^</a></b></span> <span class="reference-text"><cite id="CITEREFHonsberger1976" class="citation book cs1"><a href="Ross_Honsberger" title="Ross Honsberger">Honsberger, R.</a> (1976). <i>Mathematical Gems II</i>. The <a href="Mathematical_Association_of_America" title="Mathematical Association of America">Mathematical Association of America</a>. pp.&nbsp;<span class="nowrap">54–</span>57. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-88385-302-7</bdi>.</cite></span>
</li>
<li id="cite_note-Knuth-257-261-94"><span class="mw-cite-backlink">^ <a href="#cite_ref-Knuth-257-261_94-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Knuth-257-261_94-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp. 257–261</span>
</li>
<li id="cite_note-Crandall_2001-95"><span class="mw-cite-backlink">^ <a href="#cite_ref-Crandall_2001_95-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Crandall_2001_95-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Crandall_2001_95-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFCrandallPomerance2001">Crandall &amp; Pomerance 2001</a>, pp. 77–79, 81–85, 425–431</span>
</li>
<li id="cite_note-Moller08-96"><span class="mw-cite-backlink">^ <a href="#cite_ref-Moller08_96-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Moller08_96-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFMöller2008" class="citation journal cs1">Möller, N. (2008). <a rel="nofollow" class="external text" href="http://www.lysator.liu.se/~nisse/archive/sgcd.pdf">"On Schönhage's algorithm and subquadratic integer gcd computation"</a> <span class="cs1-format">(PDF)</span>. <i>Mathematics of Computation</i>. <b>77</b> (261): <span class="nowrap">589–</span>607. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/2008MaCom..77..589M">2008MaCom..77..589M</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1090%2FS0025-5718-07-02017-0">10.1090/S0025-5718-07-02017-0</a></span>.</cite></span>
</li>
<li id="cite_note-Knuth,_p._344-97"><span class="mw-cite-backlink">^ <a href="#cite_ref-Knuth,_p._344_97-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Knuth,_p._344_97-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Knuth,_p._344_97-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 344</span>
</li>
<li id="cite_note-98"><span class="mw-cite-backlink"><b><a href="#cite_ref-98">^</a></b></span> <span class="reference-text"><a href="#CITEREFOre1948">Ore 1948</a>, p.&nbsp;45</span>
</li>
<li id="cite_note-Knuth,_p._343-99"><span class="mw-cite-backlink">^ <a href="#cite_ref-Knuth,_p._343_99-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Knuth,_p._343_99-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 343</span>
</li>
<li id="cite_note-100"><span class="mw-cite-backlink"><b><a href="#cite_ref-100">^</a></b></span> <span class="reference-text"><a href="#CITEREFMollin2008">Mollin 2008</a>, p.&nbsp;21</span>
</li>
<li id="cite_note-101"><span class="mw-cite-backlink"><b><a href="#cite_ref-101">^</a></b></span> <span class="reference-text"><a href="#CITEREFLeVeque1996">LeVeque 1996</a>, p.&nbsp;35</span>
</li>
<li id="cite_note-102"><span class="mw-cite-backlink"><b><a href="#cite_ref-102">^</a></b></span> <span class="reference-text"><a href="#CITEREFMollin2008">Mollin 2008</a>, pp.&nbsp;21–22</span>
</li>
<li id="cite_note-103"><span class="mw-cite-backlink"><b><a href="#cite_ref-103">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 353</span>
</li>
<li id="cite_note-104"><span class="mw-cite-backlink"><b><a href="#cite_ref-104">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 357</span>
</li>
<li id="cite_note-105"><span class="mw-cite-backlink"><b><a href="#cite_ref-105">^</a></b></span> <span class="reference-text"><cite id="CITEREFTonkov1974" class="citation journal cs1">Tonkov, T. (1974). <a rel="nofollow" class="external text" href="https://doi.org/10.4064%2Faa-26-1-47-57">"On the average length of finite continued fractions"</a>. <i>Acta Arithmetica</i>. <b>26</b> (1): <span class="nowrap">47–</span>57. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.4064%2Faa-26-1-47-57">10.4064/aa-26-1-47-57</a></span>.</cite></span>
</li>
<li id="cite_note-106"><span class="mw-cite-backlink"><b><a href="#cite_ref-106">^</a></b></span> <span class="reference-text">
<cite id="CITEREFKnuth1976" class="citation journal cs1"><a href="Donald_E._Knuth" class="mw-redirect" title="Donald E. Knuth">Knuth, Donald E.</a> (1976). <a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0898-1221%2876%2990025-0">"Evaluation of Porter's constant"</a>. <i>Computers &amp; Mathematics with Applications</i>. <b>2</b> (2): <span class="nowrap">137–</span>139. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0898-1221%2876%2990025-0">10.1016/0898-1221(76)90025-0</a></span>.</cite></span>
</li>
<li id="cite_note-107"><span class="mw-cite-backlink"><b><a href="#cite_ref-107">^</a></b></span> <span class="reference-text"><cite id="CITEREFPorter1975" class="citation journal cs1">Porter, J. W. (1975). "On a Theorem of Heilbronn". <i><a href="Mathematika" title="Mathematika">Mathematika</a></i>. <b>22</b> (1): <span class="nowrap">20–</span>28. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1112%2FS0025579300004459">10.1112/S0025579300004459</a>.</cite></span>
</li>
<li id="cite_note-108"><span class="mw-cite-backlink"><b><a href="#cite_ref-108">^</a></b></span> <span class="reference-text"><cite id="CITEREFKnuth1976" class="citation journal cs1"><a href="Donald_Knuth" title="Donald Knuth">Knuth, D. E.</a> (1976). <a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0898-1221%2876%2990025-0">"Evaluation of Porter's Constant"</a>. <i>Computers and Mathematics with Applications</i>. <b>2</b> (2): <span class="nowrap">137–</span>139. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0898-1221%2876%2990025-0">10.1016/0898-1221(76)90025-0</a></span>.</cite></span>
</li>
<li id="cite_note-109"><span class="mw-cite-backlink"><b><a href="#cite_ref-109">^</a></b></span> <span class="reference-text"><cite id="CITEREFDixon1970" class="citation journal cs1">Dixon, J. D. (1970). <a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0022-314X%2870%2990044-2">"The Number of Steps in the Euclidean Algorithm"</a>. <i>J. Number Theory</i>. <b>2</b> (4): <span class="nowrap">414–</span>422. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/1970JNT.....2..414D">1970JNT.....2..414D</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0022-314X%2870%2990044-2">10.1016/0022-314X(70)90044-2</a></span>.</cite></span>
</li>
<li id="cite_note-110"><span class="mw-cite-backlink"><b><a href="#cite_ref-110">^</a></b></span> <span class="reference-text"><cite id="CITEREFHeilbronn1969" class="citation book cs1"><a href="Hans_Heilbronn" title="Hans Heilbronn">Heilbronn, H. A.</a> (1969). "On the Average Length of a Class of Finite Continued Fractions". In Paul Turán (ed.). <i>Number Theory and Analysis</i>. New York: Plenum. pp.&nbsp;<span class="nowrap">87–</span>96. <a href="LCCN_(identifier)" class="mw-redirect" title="LCCN (identifier)">LCCN</a>&nbsp;<a rel="nofollow" class="external text" href="https://lccn.loc.gov/76016027">76016027</a>.</cite></span>
</li>
<li id="cite_note-111"><span class="mw-cite-backlink"><b><a href="#cite_ref-111">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 354</span>
</li>
<li id="cite_note-Norton_1990-112"><span class="mw-cite-backlink">^ <a href="#cite_ref-Norton_1990_112-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Norton_1990_112-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFNorton1990" class="citation journal cs1">Norton, G. H. (1990). <a rel="nofollow" class="external text" href="https://doi.org/10.1016%2FS0747-7171%2808%2980036-3">"On the Asymptotic Analysis of the Euclidean Algorithm"</a>. <i>Journal of Symbolic Computation</i>. <b>10</b> (1): <span class="nowrap">53–</span>58. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1016%2FS0747-7171%2808%2980036-3">10.1016/S0747-7171(08)80036-3</a></span>.</cite></span>
</li>
<li id="cite_note-113"><span class="mw-cite-backlink"><b><a href="#cite_ref-113">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 355</span>
</li>
<li id="cite_note-114"><span class="mw-cite-backlink"><b><a href="#cite_ref-114">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 356</span>
</li>
<li id="cite_note-115"><span class="mw-cite-backlink"><b><a href="#cite_ref-115">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 352</span>
</li>
<li id="cite_note-116"><span class="mw-cite-backlink"><b><a href="#cite_ref-116">^</a></b></span> <span class="reference-text"><cite id="CITEREFWagon1999" class="citation book cs1"><a href="Stan_Wagon" title="Stan Wagon">Wagon, S.</a> (1999). <i>Mathematica in Action</i>. New York: Springer-Verlag. pp.&nbsp;<span class="nowrap">335–</span>336. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-98252-3</bdi>.</cite></span>
</li>
<li id="cite_note-117"><span class="mw-cite-backlink"><b><a href="#cite_ref-117">^</a></b></span> <span class="reference-text"><a href="#CITEREFCohen1993">Cohen 1993</a>, p.&nbsp;14</span>
</li>
<li id="cite_note-118"><span class="mw-cite-backlink"><b><a href="#cite_ref-118">^</a></b></span> <span class="reference-text"><a href="#CITEREFCohen1993">Cohen 1993</a>, pp.&nbsp;14–15, 17–18</span>
</li>
<li id="cite_note-119"><span class="mw-cite-backlink"><b><a href="#cite_ref-119">^</a></b></span> <span class="reference-text">
<cite id="CITEREFSorenson2004" class="citation book cs1">Sorenson, Jonathan P. (2004). "An analysis of the generalized binary GCD algorithm". <a rel="nofollow" class="external text" href="https://books.google.com/books?id=udr3tHHwBl0C&amp;pg=PA327"><i>High primes and misdemeanours: lectures in honour of the 60th birthday of Hugh Cowie Williams</i></a>. Fields Institute Communications. Vol.&nbsp;41. Providence, RI: American Mathematical Society. pp.&nbsp;<span class="nowrap">327–</span>340. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780821887592</bdi>. <a href="MR_(identifier)" class="mw-redirect" title="MR (identifier)">MR</a>&nbsp;<a rel="nofollow" class="external text" href="https://mathscinet.ams.org/mathscinet-getitem?mr=2076257">2076257</a>. <q>The algorithms that are used the most in practice today [for computing greatest common divisors] are probably the binary algorithm and Euclid's algorithm for smaller numbers, and either Lehmer's algorithm or Lebealean's version of the <i>k</i>-ary GCD algorithm for larger numbers.</q></cite></span>
</li>
<li id="cite_note-120"><span class="mw-cite-backlink"><b><a href="#cite_ref-120">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, pp. 321–323</span>
</li>
<li id="cite_note-121"><span class="mw-cite-backlink"><b><a href="#cite_ref-121">^</a></b></span> <span class="reference-text"><cite id="CITEREFStein1967" class="citation journal cs1">Stein, J. (1967). "Computational problems associated with Racah algebra". <i>Journal of Computational Physics</i>. <b>1</b> (3): <span class="nowrap">397–</span>405. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/1967JCoPh...1..397S">1967JCoPh...1..397S</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0021-9991%2867%2990047-2">10.1016/0021-9991(67)90047-2</a>.</cite></span>
</li>
<li id="cite_note-122"><span class="mw-cite-backlink"><b><a href="#cite_ref-122">^</a></b></span> <span class="reference-text"><a href="#CITEREFKnuth1997">Knuth 1997</a>, p. 328</span>
</li>
<li id="cite_note-123"><span class="mw-cite-backlink"><b><a href="#cite_ref-123">^</a></b></span> <span class="reference-text"><cite id="CITEREFLehmer1938" class="citation journal cs1"><a href="Derrick_Henry_Lehmer" class="mw-redirect" title="Derrick Henry Lehmer">Lehmer, D. H.</a> (1938). "Euclid's Algorithm for Large Numbers". <i>The American Mathematical Monthly</i>. <b>45</b> (4): <span class="nowrap">227–</span>233. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2302607">10.2307/2302607</a>. <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2302607">2302607</a>.</cite></span>
</li>
<li id="cite_note-124"><span class="mw-cite-backlink"><b><a href="#cite_ref-124">^</a></b></span> <span class="reference-text"><cite id="CITEREFSorenson1994" class="citation journal cs1">Sorenson, J. (1994). "Two fast GCD algorithms". <i>J. Algorithms</i>. <b>16</b> (1): <span class="nowrap">110–</span>144. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1006%2Fjagm.1994.1006">10.1006/jagm.1994.1006</a>.</cite></span>
</li>
<li id="cite_note-125"><span class="mw-cite-backlink"><b><a href="#cite_ref-125">^</a></b></span> <span class="reference-text"><cite id="CITEREFWeber1995" class="citation journal cs1">Weber, K. (1995). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F200979.201042">"The accelerated GCD algorithm"</a>. <i>ACM Trans. Math. Softw</i>. <b>21</b> (1): <span class="nowrap">111–</span>122. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F200979.201042">10.1145/200979.201042</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:14934919">14934919</a>.</cite></span>
</li>
<li id="cite_note-126"><span class="mw-cite-backlink"><b><a href="#cite_ref-126">^</a></b></span> <span class="reference-text"><cite id="CITEREFAhoHopcroftUllman1974" class="citation book cs1"><a href="Alfred_Aho" title="Alfred Aho">Aho, A.</a>; <a href="John_Hopcroft" title="John Hopcroft">Hopcroft, J.</a>; <a href="Jeffrey_Ullman" title="Jeffrey Ullman">Ullman, J.</a> (1974). <a rel="nofollow" class="external text" href="https://archive.org/details/designanalysisof00ahoarich/page/300"><i>The Design and Analysis of Computer Algorithms</i></a>. New York: Addison–Wesley. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/designanalysisof00ahoarich/page/300">300–310</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-201-00029-6</bdi>.</cite></span>
</li>
<li id="cite_note-127"><span class="mw-cite-backlink"><b><a href="#cite_ref-127">^</a></b></span> <span class="reference-text"><cite id="CITEREFSchönhage1971" class="citation journal cs1 cs1-prop-foreign-lang-source"><a href="Arnold_Sch%C3%B6nhage" title="Arnold Schönhage">Schönhage, A.</a> (1971). "Schnelle Berechnung von Kettenbruchentwicklungen". <i>Acta Informatica</i> (in German). <b>1</b> (2): <span class="nowrap">139–</span>144. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2FBF00289520">10.1007/BF00289520</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:34561609">34561609</a>.</cite></span>
</li>
<li id="cite_note-128"><span class="mw-cite-backlink"><b><a href="#cite_ref-128">^</a></b></span> <span class="reference-text"><cite id="CITEREFCesari1998" class="citation book cs1">Cesari, G. (1998). "Parallel implementation of Schönhage's integer GCD algorithm". In G. Buhler (ed.). <i>Algorithmic Number Theory: Proc. ANTS-III, Portland, OR</i>. Lecture Notes in Computer Science. Vol.&nbsp;1423. New York: Springer-Verlag. pp.&nbsp;<span class="nowrap">64–</span>76.</cite></span>
</li>
<li id="cite_note-129"><span class="mw-cite-backlink"><b><a href="#cite_ref-129">^</a></b></span> <span class="reference-text"><cite id="CITEREFStehléZimmermann2005" class="citation book cs1">Stehlé, D.; Zimmermann, P. (2005). "<a href="Gal's_accurate_tables" title="Gal's accurate tables">Gal's accurate tables</a> method revisited". <i>Proceedings of the 17th IEEE Symposium on Computer Arithmetic (ARITH-17)</i>. Los Alamitos, CA: <a href="IEEE_Computer_Society_Press" class="mw-redirect" title="IEEE Computer Society Press">IEEE Computer Society Press</a>.</cite></span>
</li>
<li id="cite_note-Lang_1984-130"><span class="mw-cite-backlink">^ <a href="#cite_ref-Lang_1984_130-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Lang_1984_130-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Lang_1984_130-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFLang1984" class="citation book cs1"><a href="Serge_Lang" title="Serge Lang">Lang, S.</a> (1984). <i>Algebra</i> (2nd&nbsp;ed.). Menlo Park, CA: Addison–Wesley. pp.&nbsp;<span class="nowrap">190–</span>194. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-201-05487-6</bdi>.</cite></span>
</li>
<li id="cite_note-weinberger-131"><span class="mw-cite-backlink">^ <a href="#cite_ref-weinberger_131-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-weinberger_131-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFWeinberger1973" class="citation journal cs1">Weinberger, P. (1973). "On Euclidean rings of algebraic integers". <i>Proc. Sympos. Pure Math</i>. Proceedings of Symposia in Pure Mathematics. <b>24</b>. Providence, Rhode Island: <span class="nowrap">321–</span>332. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1090%2Fpspum%2F024%2F0337902">10.1090/pspum/024/0337902</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780821814246</bdi>.</cite></span>
</li>
<li id="cite_note-stillwell151-152-132"><span class="mw-cite-backlink">^ <a href="#cite_ref-stillwell151-152_132-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-stillwell151-152_132-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-stillwell151-152_132-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFStillwell2003">Stillwell 2003</a>, pp.&nbsp;151–152</span>
</li>
<li id="cite_note-133"><span class="mw-cite-backlink"><b><a href="#cite_ref-133">^</a></b></span> <span class="reference-text"><cite id="CITEREFBoyerMerzbach1991" class="citation book cs1">Boyer, C. B.; <a href="Uta_Merzbach" title="Uta Merzbach">Merzbach, U. C.</a> (1991). <a rel="nofollow" class="external text" href="https://archive.org/details/historyofmathema00boye/page/116"><i>A History of Mathematics</i></a> (2nd&nbsp;ed.). New York: Wiley. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/historyofmathema00boye/page/116">116–117</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-471-54397-7</bdi>.</cite></span>
</li>
<li id="cite_note-134"><span class="mw-cite-backlink"><b><a href="#cite_ref-134">^</a></b></span> <span class="reference-text"><cite id="CITEREFCajori1894" class="citation book cs1"><a href="Florian_Cajori" title="Florian Cajori">Cajori, F</a> (1894). <a rel="nofollow" class="external text" href="https://archive.org/details/in.ernet.dli.2015.73802"><i>A History of Mathematics</i></a>. New York: Macmillan. p.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/in.ernet.dli.2015.73802/page/n78">70</a>.</cite> Reprinted, Dover Publications, 2004, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-486-43874-0</bdi></span>
</li>
<li id="cite_note-135"><span class="mw-cite-backlink"><b><a href="#cite_ref-135">^</a></b></span> <span class="reference-text"><cite id="CITEREFJoux2009" class="citation book cs1">Joux, Antoine (2009). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=buQajqt-_iUC&amp;pg=PA33"><i>Algorithmic Cryptanalysis</i></a>. CRC Press. p.&nbsp;33. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781420070033</bdi>.</cite></span>
</li>
<li id="cite_note-136"><span class="mw-cite-backlink"><b><a href="#cite_ref-136">^</a></b></span> <span class="reference-text"><cite id="CITEREFFuksTabachnikov2007" class="citation book cs1">Fuks, D. B.; <a href="Sergei_Tabachnikov" title="Sergei Tabachnikov">Tabachnikov, Serge</a> (2007). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=IiG9AwAAQBAJ&amp;pg=PA13"><i>Mathematical Omnibus: Thirty Lectures on Classic Mathematics</i></a>. American Mathematical Society. p.&nbsp;13. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780821843161</bdi>.</cite></span>
</li>
<li id="cite_note-137"><span class="mw-cite-backlink"><b><a href="#cite_ref-137">^</a></b></span> <span class="reference-text"><cite id="CITEREFDarling2004" class="citation book cs1"><a href="David_J._Darling" title="David J. Darling">Darling, David</a> (2004). "Khintchine's constant". <a rel="nofollow" class="external text" href="https://books.google.com/books?id=HrOxRdtYYaMC&amp;pg=PA175"><i>The Universal Book of Mathematics: From Abracadabra to Zeno's Paradoxes</i></a>. John Wiley &amp; Sons. p.&nbsp;175. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780471667001</bdi>.</cite></span>
</li>
<li id="cite_note-138"><span class="mw-cite-backlink"><b><a href="#cite_ref-138">^</a></b></span> <span class="reference-text"><cite id="CITEREFWilliams2010" class="citation book cs1">Williams, Colin P. (2010). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=QE8S--WjIFwC&amp;pg=PA277"><i>Explorations in Quantum Computing</i></a>. Springer. pp.&nbsp;<span class="nowrap">277–</span>278. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9781846288876</bdi>.</cite></span>
</li>
<li id="cite_note-139"><span class="mw-cite-backlink"><b><a href="#cite_ref-139">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoxLittleO'Shea1997">Cox, Little &amp; O'Shea 1997</a>, pp.&nbsp;37–46</span>
</li>
<li id="cite_note-140"><span class="mw-cite-backlink"><b><a href="#cite_ref-140">^</a></b></span> <span class="reference-text"><a href="#CITEREFSchroeder2005">Schroeder 2005</a>, pp.&nbsp;254–259</span>
</li>
<li id="cite_note-141"><span class="mw-cite-backlink"><b><a href="#cite_ref-141">^</a></b></span> <span class="reference-text"><cite id="CITEREFGrattan-Guinness1990" class="citation book cs1"><a href="Ivor_Grattan-Guinness" title="Ivor Grattan-Guinness">Grattan-Guinness, Ivor</a> (1990). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=_GgioErrbW8C&amp;pg=PA1148"><i>Convolutions in French Mathematics, 1800-1840: From the Calculus and Mechanics to Mathematical Analysis and Mathematical Physics. Volume II: The Turns</i></a>. Science Networks: Historical Studies. Vol.&nbsp;3. Basel, Boston, Berlin: Birkhäuser. p.&nbsp;1148. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9783764322380</bdi>. <q>Our subject here is the 'Sturm sequence' of functions defined from a function and its derivative by means of Euclid's algorithm, in order to calculate the number of real roots of a polynomial within a given interval</q></cite></span>
</li>
<li id="cite_note-142"><span class="mw-cite-backlink"><b><a href="#cite_ref-142">^</a></b></span> <span class="reference-text"><cite id="CITEREFHairerNørsettWanner1993" class="citation book cs1">Hairer, Ernst; Nørsett, Syvert P.; Wanner, Gerhard (1993). "The Routh–Hurwitz Criterion". <a rel="nofollow" class="external text" href="https://books.google.com/books?id=F93u7VcSRyYC&amp;pg=PA81"><i>Solving Ordinary Differential Equations I: Nonstiff Problems</i></a>. Springer Series in Computational Mathematics. Vol.&nbsp;8 (2nd&nbsp;ed.). Springer. pp.&nbsp;81ff. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9783540566700</bdi>.</cite></span>
</li>
<li id="cite_note-Stillwell_2003-144"><span class="mw-cite-backlink">^ <a href="#cite_ref-Stillwell_2003_144-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Stillwell_2003_144-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Stillwell_2003_144-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFStillwell2003">Stillwell 2003</a>, pp.&nbsp;101–116</span>
</li>
<li id="cite_note-hensley-145"><span class="mw-cite-backlink">^ <a href="#cite_ref-hensley_145-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-hensley_145-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-hensley_145-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFHensley2006" class="citation book cs1">Hensley, Doug (2006). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=k3PVXFkweKgC&amp;pg=PA26"><i>Continued Fractions</i></a>. World Scientific. p.&nbsp;26. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9789812564771</bdi>.</cite></span>
</li>
<li id="cite_note-146"><span class="mw-cite-backlink"><b><a href="#cite_ref-146">^</a></b></span> <span class="reference-text"><cite id="CITEREFDedekind1996" class="citation book cs1"><a href="Richard_Dedekind" title="Richard Dedekind">Dedekind, Richard</a> (1996). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=KZRBabJY4ewC&amp;pg=PA222"><i>Theory of Algebraic Integers</i></a>. Cambridge Mathematical Library. Cambridge University Press. pp.&nbsp;<span class="nowrap">22–</span>24. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780521565189</bdi>.</cite></span>
</li>
<li id="cite_note-147"><span class="mw-cite-backlink"><b><a href="#cite_ref-147">^</a></b></span> <span class="reference-text"><cite id="CITEREFJohnstonRichman1997" class="citation book cs1">Johnston, Bernard L.; Richman, Fred (1997). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=koUfrlgsmUcC&amp;pg=PA44"><i>Numbers and Symmetry: An Introduction to Algebra</i></a>. CRC Press. p.&nbsp;44. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780849303012</bdi>.</cite></span>
</li>
<li id="cite_note-148"><span class="mw-cite-backlink"><b><a href="#cite_ref-148">^</a></b></span> <span class="reference-text"><cite id="CITEREFAdamsGoldstein1976" class="citation book cs1">Adams, William W.; Goldstein, Larry Joel (1976). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/introductiontonu0000adam"><i>Introduction to Number Theory</i></a></span>. Prentice-Hall. Exercise 24, p.&nbsp;205. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780134912820</bdi>. <q>State and prove an analogue of the Chinese remainder theorem for the Gaussian integers.</q></cite></span>
</li>
<li id="cite_note-149"><span class="mw-cite-backlink"><b><a href="#cite_ref-149">^</a></b></span> <span class="reference-text"><a href="#CITEREFStark1978">Stark 1978</a>, p.&nbsp;290</span>
</li>
<li id="cite_note-150"><span class="mw-cite-backlink"><b><a href="#cite_ref-150">^</a></b></span> <span class="reference-text"><a href="#CITEREFCohn1980">Cohn 1980</a>, pp.&nbsp;104–105</span>
</li>
<li id="cite_note-151"><span class="mw-cite-backlink"><b><a href="#cite_ref-151">^</a></b></span> <span class="reference-text"><cite id="CITEREFLauritzen2003" class="citation book cs1">Lauritzen, Niels (2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=BdAbcje-TZUC&amp;pg=PA130"><i>Concrete Abstract Algebra: From Numbers to Gröbner Bases</i></a>. Cambridge University Press. p.&nbsp;130. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780521534109</bdi>.</cite></span>
</li>
<li id="cite_note-152"><span class="mw-cite-backlink"><b><a href="#cite_ref-152">^</a></b></span> <span class="reference-text"><a href="#CITEREFLauritzen2003">Lauritzen (2003)</a>, p.&nbsp;132</span>
</li>
<li id="cite_note-153"><span class="mw-cite-backlink"><b><a href="#cite_ref-153">^</a></b></span> <span class="reference-text"><a href="#CITEREFLauritzen2003">Lauritzen (2003)</a>, p.&nbsp;161</span>
</li>
<li id="cite_note-sharpe-154"><span class="mw-cite-backlink">^ <a href="#cite_ref-sharpe_154-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-sharpe_154-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFSharpe1987" class="citation book cs1">Sharpe, David (1987). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/ringsfactorizati0000shar"><i>Rings and Factorization</i></a></span>. Cambridge University Press. p.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/ringsfactorizati0000shar/page/55">55</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780521337182</bdi>.</cite></span>
</li>
<li id="cite_note-155"><span class="mw-cite-backlink"><b><a href="#cite_ref-155">^</a></b></span> <span class="reference-text"><a href="#CITEREFSharpe1987">Sharpe (1987)</a>, p.&nbsp;52</span>
</li>
<li id="cite_note-156"><span class="mw-cite-backlink"><b><a href="#cite_ref-156">^</a></b></span> <span class="reference-text"><a href="#CITEREFLauritzen2003">Lauritzen (2003)</a>, p.&nbsp;131</span>
</li>
<li id="cite_note-157"><span class="mw-cite-backlink"><b><a href="#cite_ref-157">^</a></b></span> <span class="reference-text"><cite id="CITEREFLamé1847" class="citation journal cs1 cs1-prop-foreign-lang-source"><a href="Gabriel_Lam%C3%A9" title="Gabriel Lamé">Lamé, G.</a> (1847). "Mémoire sur la résolution, en nombres complexes, de l'équation A<sup>n</sup> + B<sup>n</sup> + C<sup>n</sup> = 0". <i>J. Math. Pures Appl.</i> (in French). <b>12</b>: <span class="nowrap">172–</span>184.</cite></span>
</li>
<li id="cite_note-158"><span class="mw-cite-backlink"><b><a href="#cite_ref-158">^</a></b></span> <span class="reference-text"><cite id="CITEREFEdwards2000" class="citation book cs1"><a href="Harold_Edwards_(mathematician)" title="Harold Edwards (mathematician)">Edwards, H.</a> (2000). <i>Fermat's last theorem: a genetic introduction to algebraic number theory</i>. Springer. p.&nbsp;76.</cite></span>
</li>
<li id="cite_note-159"><span class="mw-cite-backlink"><b><a href="#cite_ref-159">^</a></b></span> <span class="reference-text"><a href="#CITEREFCohn1980">Cohn 1980</a>, pp.&nbsp;104–110</span>
</li>
<li id="cite_note-160"><span class="mw-cite-backlink"><b><a href="#cite_ref-160">^</a></b></span> <span class="reference-text"><cite id="CITEREFLeVeque2002" class="citation book cs1"><a href="William_J._LeVeque" title="William J. LeVeque">LeVeque, W. J.</a> (2002) [1956]. <a rel="nofollow" class="external text" href="https://archive.org/details/topicsinnumberth0000leve"><i>Topics in Number Theory, Volumes I and II</i></a>. New York: Dover Publications. pp.&nbsp;II:57, 81. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-486-42539-9</bdi>. <a href="Zbl_(identifier)" class="mw-redirect" title="Zbl (identifier)">Zbl</a>&nbsp;<a rel="nofollow" class="external text" href="https://zbmath.org/?format=complete&amp;q=an:1009.11001">1009.11001</a>.</cite></span>
</li>
<li id="cite_note-Clark_1994-161"><span class="mw-cite-backlink">^ <a href="#cite_ref-Clark_1994_161-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Clark_1994_161-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFClark1994" class="citation journal cs1">Clark, D. A. (1994). <a rel="nofollow" class="external text" href="https://doi.org/10.1007%2FBF02567617">"A quadratic field which is Euclidean but not norm-Euclidean"</a>. <i>Manuscripta Mathematica</i>. <b>83</b> (1): <span class="nowrap">327–</span>330. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1007%2FBF02567617">10.1007/BF02567617</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:895185">895185</a>. <a href="Zbl_(identifier)" class="mw-redirect" title="Zbl (identifier)">Zbl</a>&nbsp;<a rel="nofollow" class="external text" href="https://zbmath.org/?format=complete&amp;q=an:0817.11047">0817.11047</a>.</cite></span>
</li>
<li id="cite_note-bgv-162"><span class="mw-cite-backlink">^ <a href="#cite_ref-bgv_162-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-bgv_162-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-bgv_162-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBuesoGómez-TorrecillasVerschoren2003">Bueso, Gómez-Torrecillas &amp; Verschoren (2003)</a>; see pp. 37-38 for non-commutative extensions of the Euclidean algorithm and Corollary 4.35, p. 40, for more examples of noncommutative rings to which they apply.</span>
</li>
<li id="cite_note-entgtrg-163"><span class="mw-cite-backlink">^ <a href="#cite_ref-entgtrg_163-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-entgtrg_163-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFDavidoffSarnakValette2003" class="citation book cs1"><a href="Giuliana_Davidoff" title="Giuliana Davidoff">Davidoff, Giuliana</a>; Sarnak, Peter; Valette, Alain (2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=AlvfFDJOGZ8C&amp;pg=PA59">"2.6 The Arithmetic of Integer Quaternions"</a>. <a href="Elementary_Number_Theory%2C_Group_Theory_and_Ramanujan_Graphs" title="Elementary Number Theory, Group Theory and Ramanujan Graphs"><i>Elementary Number Theory, Group Theory and Ramanujan Graphs</i></a>. London Mathematical Society Student Texts. Vol.&nbsp;55. Cambridge University Press. pp.&nbsp;<span class="nowrap">59–</span>70. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780521531436</bdi>.</cite></span>
</li>
<li id="cite_note-164"><span class="mw-cite-backlink"><b><a href="#cite_ref-164">^</a></b></span> <span class="reference-text"><cite id="CITEREFRibenboim2001" class="citation book cs1">Ribenboim, Paulo (2001). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=u5443xdaNZcC&amp;pg=PA104"><i>Classical Theory of Algebraic Numbers</i></a>. Universitext. Springer-Verlag. p.&nbsp;104. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780387950709</bdi>.</cite></span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="Bibliography">Bibliography</h2></div>
<ul><li><cite id="CITEREFBuesoGómez-TorrecillasVerschoren2003" class="citation book cs1">Bueso, José; Gómez-Torrecillas, José; Verschoren, Alain (2003). <i>Algorithmic Methods in Non-Commutative Algebra: Applications to Quantum Groups</i>. Mathematical Modelling: Theory and Applications. Vol.&nbsp;17. Kluwer Academic Publishers, Dordrecht. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-94-017-0285-0">10.1007/978-94-017-0285-0</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>1-4020-1402-3</bdi>. <a href="MR_(identifier)" class="mw-redirect" title="MR (identifier)">MR</a>&nbsp;<a rel="nofollow" class="external text" href="https://mathscinet.ams.org/mathscinet-getitem?mr=2006329">2006329</a>.</cite></li>
<li><cite id="CITEREFCohen1993" class="citation book cs1"><a href="Henri_Cohen_(number_theorist)" title="Henri Cohen (number theorist)">Cohen, H.</a> (1993). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=hXGr-9l1DXcC"><i>A Course in Computational Algebraic Number Theory</i></a>. New York: Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-55640-0</bdi>.</cite></li>
<li><cite id="CITEREFCohn1980" class="citation book cs1">Cohn, H. (1980). <a rel="nofollow" class="external text" href="https://archive.org/details/Cohn_Harvey_-_Advanced_Number_Theory/mode/2up"><i>Advanced Number Theory</i></a>. New York: Dover. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-486-64023-X</bdi>.</cite></li>
<li><cite id="CITEREFCoxLittleO'Shea1997" class="citation book cs1"><a href="David_A._Cox" title="David A. Cox">Cox, D.</a>; Little, J.; <a href="Donal_O'Shea" title="Donal O'Shea">O'Shea, D.</a> (1997). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=7eLkq0wQytAC"><i>Ideals, Varieties, and Algorithms: An Introduction to Computational Algebraic Geometry and Commutative Algebra</i></a> (2nd&nbsp;ed.). Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-94680-2</bdi>.</cite></li>
<li><cite id="CITEREFCrandallPomerance2001" class="citation book cs1"><a href="Richard_Crandall" title="Richard Crandall">Crandall, R.</a>; <a href="Carl_Pomerance" title="Carl Pomerance">Pomerance, C.</a> (2001). <i>Prime Numbers: A Computational Perspective</i> (1st&nbsp;ed.). New York: Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-94777-9</bdi>.</cite></li>
<li><cite id="CITEREFLejeune_Dirichlet1894" class="citation book cs1 cs1-prop-foreign-lang-source"><a href="Peter_Gustav_Lejeune_Dirichlet" title="Peter Gustav Lejeune Dirichlet">Lejeune Dirichlet, P. G.</a> (1894). <a href="Richard_Dedekind" title="Richard Dedekind">Dedekind, Richard</a> (ed.). <a rel="nofollow" class="external text" href="https://archive.org/details/vorlesungenberz02dirigoog"><i>Vorlesungen über Zahlentheorie (Lectures on Number Theory)</i></a> (in German). Braunschweig: Vieweg. <a href="LCCN_(identifier)" class="mw-redirect" title="LCCN (identifier)">LCCN</a>&nbsp;<a rel="nofollow" class="external text" href="https://lccn.loc.gov/03005859">03005859</a>. <a href="OCLC_(identifier)" class="mw-redirect" title="OCLC (identifier)">OCLC</a>&nbsp;<a rel="nofollow" class="external text" href="https://search.worldcat.org/oclc/490186017">490186017</a>.</cite>. See also <a href="Vorlesungen_%C3%BCber_Zahlentheorie" title="Vorlesungen über Zahlentheorie">Vorlesungen über Zahlentheorie</a></li>
<li><cite id="CITEREFKnuth1997" class="citation book cs1"><a href="Donald_Knuth" title="Donald Knuth">Knuth, D. E.</a> (1997). <i><a href="The_Art_of_Computer_Programming" title="The Art of Computer Programming">The Art of Computer Programming</a>, Volume 2: Seminumerical Algorithms</i> (3rd&nbsp;ed.). Addison–Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-201-89684-2</bdi>.</cite></li>
<li><cite id="CITEREFLeVeque1996" class="citation book cs1"><a href="William_J._LeVeque" title="William J. LeVeque">LeVeque, W. J.</a> (1996) [1977]. <i>Fundamentals of Number Theory</i>. New York: Dover. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-486-68906-9</bdi>.</cite></li>
<li><cite id="CITEREFMollin2008" class="citation book cs1">Mollin, R. A. (2008). <i>Fundamental Number Theory with Applications</i> (2nd&nbsp;ed.). Boca Raton: Chapman &amp; Hall/CRC. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1-4200-6659-3</bdi>.</cite></li>
<li><cite id="CITEREFOre1948" class="citation book cs1"><a href="%C3%98ystein_Ore" title="Øystein Ore">Ore, O.</a> (1948). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/numbertheoryitsh00ore"><i>Number Theory and Its History</i></a></span>. New York: McGraw–Hill.</cite></li>
<li><cite id="CITEREFRosen2000" class="citation book cs1">Rosen, K. H. (2000). <i>Elementary Number Theory and its Applications</i> (4th&nbsp;ed.). Reading, MA: Addison–Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-201-87073-8</bdi>.</cite></li>
<li><cite id="CITEREFSchroeder2005" class="citation book cs1"><a href="Manfred_R._Schroeder" title="Manfred R. Schroeder">Schroeder, M.</a> (2005). <i>Number Theory in Science and Communication</i> (4th&nbsp;ed.). Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-15800-6</bdi>.</cite></li>
<li><cite id="CITEREFStark1978" class="citation book cs1"><a href="Harold_Stark" title="Harold Stark">Stark, H.</a> (1978). <a rel="nofollow" class="external text" href="https://archive.org/details/introductiontonu00star_0"><i>An Introduction to Number Theory</i></a>. MIT Press. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-262-69060-8</bdi>.</cite></li>
<li><cite id="CITEREFStillwell1997" class="citation book cs1"><a href="John_Stillwell" title="John Stillwell">Stillwell, J.</a> (1997). <i>Numbers and Geometry</i>. New York: Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-98289-2</bdi>.</cite></li>
<li><cite id="CITEREFStillwell2003" class="citation book cs1">Stillwell, J. (2003). <i>Elements of Number Theory</i>. New York: Springer-Verlag. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-95587-9</bdi>.</cite></li>
<li><cite id="CITEREFTattersall2005" class="citation book cs1">Tattersall, J. J. (2005). <i>Elementary Number Theory in Nine Chapters</i>. Cambridge: <a href="Cambridge_University_Press" title="Cambridge University Press">Cambridge University Press</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-521-85014-8</bdi>.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://www.math.sc.edu/~sumner/numbertheory/euclidean/euclidean.html">Demonstrations of Euclid's algorithm</a></li>
<li><span class="citation mathworld" id="Reference-Mathworld-Euclidean_Algorithm"><cite id="CITEREFWeisstein" class="citation web cs1"><a href="Eric_W._Weisstein" title="Eric W. Weisstein">Weisstein, Eric W.</a> <a rel="nofollow" class="external text" href="https://mathworld.wolfram.com/EuclideanAlgorithm.html">"Euclidean Algorithm"</a>. <i><a href="MathWorld" title="MathWorld">MathWorld</a></i>.</cite></span></li>
<li><a rel="nofollow" class="external text" href="http://www.cut-the-knot.org/blue/Euclid.shtml">Euclid's Algorithm</a> at <a href="Cut-the-knot" class="mw-redirect" title="Cut-the-knot">cut-the-knot</a></li>
<li><a rel="nofollow" class="external text" href="https://planetmath.org/EuclidsAlgorithm">Euclid's algorithm</a> at <a href="PlanetMath" title="PlanetMath">PlanetMath</a>.</li>
<li><a rel="nofollow" class="external text" href="http://www.mathpages.com/home/kmath384.htm">The Euclidean Algorithm</a> at MathPages</li>
<li><a rel="nofollow" class="external text" href="http://www.cut-the-knot.org/blue/EuclidAlg.shtml">Euclid's Game</a> at <a href="Cut-the-knot" class="mw-redirect" title="Cut-the-knot">cut-the-knot</a></li>
<li><a rel="nofollow" class="external text" href="http://plus.maths.org/issue40/features/wardhaugh/index.html">Music and Euclid's algorithm</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Number-theoretic_algorithms413" style="padding:3px"><table class="nowraplinks mw-collapsible uncollapsed navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Number-theoretic_algorithms413" style="font-size:114%;margin:0 4em"><a href="Number_theory" title="Number theory">Number-theoretic</a> <a href="Algorithm" title="Algorithm">algorithms</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Primality_test" title="Primality test">Primality tests</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="AKS_primality_test" title="AKS primality test">AKS</a></li>
<li><a href="Adleman%E2%80%93Pomerance%E2%80%93Rumely_primality_test" title="Adleman–Pomerance–Rumely primality test">APR</a></li>
<li><a href="Baillie%E2%80%93PSW_primality_test" title="Baillie–PSW primality test">Baillie–PSW</a></li>
<li><a href="Elliptic_curve_primality" title="Elliptic curve primality">Elliptic curve</a></li>
<li><a href="Pocklington_primality_test" title="Pocklington primality test">Pocklington</a></li>
<li><a href="Fermat_primality_test" title="Fermat primality test">Fermat</a></li>
<li><a href="Lucas_primality_test" title="Lucas primality test">Lucas</a></li>
<li><i><a href="Lucas%E2%80%93Lehmer_primality_test" title="Lucas–Lehmer primality test">Lucas–Lehmer</a></i></li>
<li><i><a href="Lucas%E2%80%93Lehmer%E2%80%93Riesel_test" title="Lucas–Lehmer–Riesel test">Lucas–Lehmer–Riesel</a></i></li>
<li><i><a href="Proth's_theorem" title="Proth's theorem">Proth's theorem</a></i></li>
<li><i><a href="P%C3%A9pin's_test" title="Pépin's test">Pépin's</a></i></li>
<li><a href="Quadratic_Frobenius_test" title="Quadratic Frobenius test">Quadratic Frobenius</a></li>
<li><a href="Solovay%E2%80%93Strassen_primality_test" title="Solovay–Strassen primality test">Solovay–Strassen</a></li>
<li><a href="Miller%E2%80%93Rabin_primality_test" title="Miller–Rabin primality test">Miller–Rabin</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Generating_primes" class="mw-redirect" title="Generating primes">Prime-generating</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Sieve_of_Atkin" title="Sieve of Atkin">Sieve of Atkin</a></li>
<li><a href="Sieve_of_Eratosthenes" title="Sieve of Eratosthenes">Sieve of Eratosthenes</a></li>
<li><a href="Sieve_of_Pritchard" title="Sieve of Pritchard">Sieve of Pritchard</a></li>
<li><a href="Sieve_of_Sundaram" title="Sieve of Sundaram">Sieve of Sundaram</a></li>
<li><a href="Wheel_factorization" title="Wheel factorization">Wheel factorization</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Integer_factorization" title="Integer factorization">Integer factorization</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Continued_fraction_factorization" title="Continued fraction factorization">Continued fraction (CFRAC)</a></li>
<li><a href="Dixon's_factorization_method" title="Dixon's factorization method">Dixon's</a></li>
<li><a href="Lenstra_elliptic-curve_factorization" title="Lenstra elliptic-curve factorization">Lenstra elliptic curve (ECM)</a></li>
<li><a href="Euler's_factorization_method" title="Euler's factorization method">Euler's</a></li>
<li><a href="Pollard's_rho_algorithm" title="Pollard's rho algorithm">Pollard's rho</a></li>
<li><a href="Pollard's_p_%E2%88%92_1_algorithm" title="Pollard's p − 1 algorithm"><i>p</i> − 1</a></li>
<li><a href="Williams's_p_%2B_1_algorithm" title="Williams's p + 1 algorithm"><i>p</i> + 1</a></li>
<li><a href="Quadratic_sieve" title="Quadratic sieve">Quadratic sieve (QS)</a></li>
<li><a href="General_number_field_sieve" title="General number field sieve">General number field sieve (GNFS)</a></li>
<li><i><a href="Special_number_field_sieve" title="Special number field sieve">Special number field sieve (SNFS)</a></i></li>
<li><a href="Rational_sieve" title="Rational sieve">Rational sieve</a></li>
<li><a href="Fermat's_factorization_method" title="Fermat's factorization method">Fermat's</a></li>
<li><a href="Shanks's_square_forms_factorization" title="Shanks's square forms factorization">Shanks's square forms</a></li>
<li><a href="Trial_division" title="Trial division">Trial division</a></li>
<li><a href="Shor's_algorithm" title="Shor's algorithm">Shor's</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Multiplication_algorithm" title="Multiplication algorithm">Multiplication</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ancient_Egyptian_multiplication" title="Ancient Egyptian multiplication">Ancient Egyptian</a></li>
<li><a href="Long_multiplication" class="mw-redirect" title="Long multiplication">Long</a></li>
<li><a href="Karatsuba_algorithm" title="Karatsuba algorithm">Karatsuba</a></li>
<li><a href="Toom%E2%80%93Cook_multiplication" title="Toom–Cook multiplication">Toom–Cook</a></li>
<li><a href="Sch%C3%B6nhage%E2%80%93Strassen_algorithm" title="Schönhage–Strassen algorithm">Schönhage–Strassen</a></li>
<li><a href="F%C3%BCrer's_algorithm" class="mw-redirect" title="Fürer's algorithm">Fürer's</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Euclidean_division" title="Euclidean division">Euclidean</a> <a href="Division_algorithm" title="Division algorithm">division</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_division" class="mw-redirect" title="Binary division">Binary</a></li>
<li><a href="Chunking_(division)" title="Chunking (division)">Chunking</a></li>
<li><a href="Fourier_division" title="Fourier division">Fourier</a></li>
<li><a href="Goldschmidt_division" class="mw-redirect" title="Goldschmidt division">Goldschmidt</a></li>
<li><a href="Newton%E2%80%93Raphson_division" class="mw-redirect" title="Newton–Raphson division">Newton-Raphson</a></li>
<li><a href="Long_division" title="Long division">Long</a></li>
<li><a href="Short_division" title="Short division">Short</a></li>
<li><a href="SRT_division" class="mw-redirect" title="SRT division">SRT</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Discrete_logarithm" title="Discrete logarithm">Discrete logarithm</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Baby-step_giant-step" title="Baby-step giant-step">Baby-step giant-step</a></li>
<li><a href="Pollard's_rho_algorithm_for_logarithms" title="Pollard's rho algorithm for logarithms">Pollard rho</a></li>
<li><a href="Pollard's_kangaroo_algorithm" title="Pollard's kangaroo algorithm">Pollard kangaroo</a></li>
<li><a href="Pohlig%E2%80%93Hellman_algorithm" title="Pohlig–Hellman algorithm">Pohlig–Hellman</a></li>
<li><a href="Index_calculus_algorithm" title="Index calculus algorithm">Index calculus</a></li>
<li><a href="Function_field_sieve" title="Function field sieve">Function field sieve</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Greatest_common_divisor" title="Greatest common divisor">Greatest common divisor</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_GCD_algorithm" title="Binary GCD algorithm">Binary</a></li>

<li><a href="Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">Extended Euclidean</a></li>
<li><a href="Lehmer's_GCD_algorithm" title="Lehmer's GCD algorithm">Lehmer's</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Quadratic_residue" title="Quadratic residue">Modular square root</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Cipolla's_algorithm" title="Cipolla's algorithm">Cipolla</a></li>
<li><a href="Pocklington's_algorithm" title="Pocklington's algorithm">Pocklington's</a></li>
<li><a href="Tonelli%E2%80%93Shanks_algorithm" title="Tonelli–Shanks algorithm">Tonelli–Shanks</a></li>
<li><a href="Berlekamp%E2%80%93Rabin_algorithm" title="Berlekamp–Rabin algorithm">Berlekamp</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other algorithms</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chakravala_method" title="Chakravala method">Chakravala</a></li>
<li><a href="Cornacchia's_algorithm" title="Cornacchia's algorithm">Cornacchia</a></li>
<li><a href="Exponentiation_by_squaring" title="Exponentiation by squaring">Exponentiation by squaring</a></li>
<li><a href="Integer_square_root" title="Integer square root">Integer square root</a></li>
<li><a href="Integer_relation_algorithm" title="Integer relation algorithm">Integer relation</a> (<a href="Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz_lattice_basis_reduction_algorithm" title="Lenstra–Lenstra–Lovász lattice basis reduction algorithm">LLL</a>; <a href="Korkine%E2%80%93Zolotarev_lattice_basis_reduction_algorithm" title="Korkine–Zolotarev lattice basis reduction algorithm">KZ</a>)</li>
<li><a href="Modular_exponentiation" title="Modular exponentiation">Modular exponentiation</a></li>
<li><a href="Montgomery_reduction" class="mw-redirect" title="Montgomery reduction">Montgomery reduction</a></li>
<li><a href="Schoof's_algorithm" title="Schoof's algorithm">Schoof</a></li>
<li><a href="Trachtenberg_system" title="Trachtenberg system">Trachtenberg system</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow hlist" colspan="2"><div>
<ul><li><i>Italics</i> indicate that algorithm is for numbers of special forms</li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="Ancient_Greek_mathematics550" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Ancient_Greek_mathematics550" style="font-size:114%;margin:0 4em"><a href="Ancient_Greek_mathematics" title="Ancient Greek mathematics">Ancient Greek mathematics</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="List_of_Greek_mathematicians" title="List of Greek mathematicians">Mathematicians</a><br><a href="Timeline_of_ancient_Greek_mathematicians" title="Timeline of ancient Greek mathematicians">(timeline)</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Anaxagoras" title="Anaxagoras">Anaxagoras</a></li>
<li><a href="Anthemius_of_Tralles" title="Anthemius of Tralles">Anthemius</a></li>
<li><a href="Apollonius_of_Perga" title="Apollonius of Perga">Apollonius</a></li>
<li><a href="Archimedes" title="Archimedes">Archimedes</a></li>
<li><a href="Archytas" title="Archytas">Archytas</a></li>
<li><a href="Aristaeus_the_Elder" title="Aristaeus the Elder">Aristaeus the Elder</a></li>
<li><a href="Aristarchus_of_Samos" title="Aristarchus of Samos">Aristarchus</a></li>
<li><a href="Autolycus_of_Pitane" title="Autolycus of Pitane">Autolycus</a></li>
<li><a href="Bion_of_Abdera" title="Bion of Abdera">Bion</a></li>
<li><a href="Bryson_of_Heraclea" title="Bryson of Heraclea">Bryson</a></li>
<li><a href="Callippus" title="Callippus">Callippus</a></li>
<li><a href="Carpus_of_Antioch" title="Carpus of Antioch">Carpus</a></li>
<li><a href="Chrysippus" title="Chrysippus">Chrysippus</a></li>
<li><a href="Cleomedes" title="Cleomedes">Cleomedes</a></li>
<li><a href="Conon_of_Samos" title="Conon of Samos">Conon</a></li>
<li><a href="Ctesibius" title="Ctesibius">Ctesibius</a></li>
<li><a href="Democritus" title="Democritus">Democritus</a></li>
<li><a href="Dicaearchus" title="Dicaearchus">Dicaearchus</a></li>
<li><a href="Dinostratus" title="Dinostratus">Dinostratus</a></li>
<li><a href="Diocles_(mathematician)" title="Diocles (mathematician)">Diocles</a></li>
<li><a href="Dionysodorus" title="Dionysodorus">Dionysodorus of Caunus</a></li>
<li><a href="Dionysodorus_of_Amisene" title="Dionysodorus of Amisene">Dionysodorus of Amisene</a></li>
<li><a href="Diophantus" title="Diophantus">Diophantus</a></li>
<li><a href="Domninus_of_Larissa" title="Domninus of Larissa">Domninus</a></li>
<li><a href="Eratosthenes" title="Eratosthenes">Eratosthenes</a></li>
<li><a href="Euclid" title="Euclid">Euclid</a></li>
<li><a href="Eudemus_of_Rhodes" title="Eudemus of Rhodes">Eudemus</a></li>
<li><a href="Eudoxus_of_Cnidus" title="Eudoxus of Cnidus">Eudoxus</a></li>
<li><a href="Eutocius_of_Ascalon" title="Eutocius of Ascalon">Eutocius</a></li>
<li><a href="Geminus" title="Geminus">Geminus</a></li>
<li><a href="Heliodorus_of_Larissa" title="Heliodorus of Larissa">Heliodorus</a></li>
<li><a href="Hero_of_Alexandria" title="Hero of Alexandria">Heron</a></li>
<li><a href="Hipparchus" title="Hipparchus">Hipparchus</a></li>
<li><a href="Hippasus" title="Hippasus">Hippasus</a></li>
<li><a href="Hippias" title="Hippias">Hippias</a></li>
<li><a href="Hippocrates_of_Chios" title="Hippocrates of Chios">Hippocrates</a></li>
<li><a href="Hypatia" title="Hypatia">Hypatia</a></li>
<li><a href="Hypsicles" title="Hypsicles">Hypsicles</a></li>
<li><a href="Isidore_of_Miletus" title="Isidore of Miletus">Isidore of Miletus</a></li>
<li><a href="Leon_(mathematician)" title="Leon (mathematician)">Leon</a></li>
<li><a href="Marinus_of_Neapolis" title="Marinus of Neapolis">Marinus</a></li>
<li><a href="Menaechmus" title="Menaechmus">Menaechmus</a></li>
<li><a href="Menelaus_of_Alexandria" title="Menelaus of Alexandria">Menelaus</a></li>
<li><a href="Metrodorus_(grammarian)" title="Metrodorus (grammarian)">Metrodorus</a></li>
<li><a href="Nicomachus" title="Nicomachus">Nicomachus</a></li>
<li><a href="Nicomedes_(mathematician)" title="Nicomedes (mathematician)">Nicomedes</a></li>
<li><a href="Nicoteles_of_Cyrene" title="Nicoteles of Cyrene">Nicoteles</a></li>
<li><a href="Oenopides" title="Oenopides">Oenopides</a></li>
<li><a href="Pandrosion" title="Pandrosion">Pandrosion</a></li>
<li><a href="Pappus_of_Alexandria" title="Pappus of Alexandria">Pappus</a></li>
<li><a href="Perseus_(geometer)" title="Perseus (geometer)">Perseus</a></li>
<li><a href="Philolaus" title="Philolaus">Philolaus</a></li>
<li><a href="Philon" title="Philon">Philon</a></li>
<li><a href="Philonides_of_Laodicea" title="Philonides of Laodicea">Philonides</a></li>
<li><a href="Porphyry_of_Tyre" title="Porphyry of Tyre">Porphyry of Tyre</a></li>
<li><a href="Posidonius" title="Posidonius">Posidonius</a></li>
<li><a href="Proclus" title="Proclus">Proclus</a></li>
<li><a href="Ptolemy" title="Ptolemy">Ptolemy</a></li>
<li><a href="Pythagoras" title="Pythagoras">Pythagoras</a></li>
<li><a href="Serenus_of_Antino%C3%B6polis" title="Serenus of Antinoöpolis">Serenus</a></li>
<li><a href="Sosigenes_of_Alexandria" class="mw-redirect" title="Sosigenes of Alexandria">Sosigenes</a></li>
<li><a href="Sporus_of_Nicaea" title="Sporus of Nicaea">Sporus</a></li>
<li><a href="Thales_of_Miletus" title="Thales of Miletus">Thales</a></li>
<li><a href="Theaetetus_(mathematician)" title="Theaetetus (mathematician)">Theaetetus</a></li>
<li><a href="Theodorus_of_Cyrene" title="Theodorus of Cyrene">Theodorus</a></li>
<li><a href="Theodosius_of_Bithynia" title="Theodosius of Bithynia">Theodosius</a></li>
<li><a href="Theon_of_Alexandria" title="Theon of Alexandria">Theon of Alexandria</a></li>
<li><a href="Theon_of_Smyrna" title="Theon of Smyrna">Theon of Smyrna</a></li>
<li><a href="Thymaridas" title="Thymaridas">Thymaridas</a></li>
<li><a href="Xenocrates" title="Xenocrates">Xenocrates</a></li>
<li><a href="Zeno_of_Elea" title="Zeno of Elea">Zeno of Elea</a></li>
<li><a href="Zeno_of_Sidon" title="Zeno of Sidon">Zeno of Sidon</a></li>
<li><a href="Zenodorus_(mathematician)" title="Zenodorus (mathematician)">Zenodorus</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Treatises</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><i><a href="Almagest" title="Almagest">Almagest</a></i></li>
<li><i><a href="Arithmetica" class="mw-redirect" title="Arithmetica">Arithmetica</a></i></li>
<li><a href="Apollonius_of_Perga#Conics" title="Apollonius of Perga"><i>Conics</i> <span style="font-size: 85%;">(Apollonius)</span></a></li>
<li><i><a href="Catoptrics" title="Catoptrics">Catoptrics</a></i></li>
<li><a href="Data_(Euclid)" class="mw-redirect" title="Data (Euclid)"><i>Data</i> <span style="font-size: 85%;">(Euclid)</span></a></li>
<li><a href="Euclid's_Elements" title="Euclid's Elements"><i>Elements</i> <span style="font-size: 85%;">(Euclid)</span></a></li>
<li><i><a href="Little_Astronomy" title="Little Astronomy">Little Astronomy</a></i></li>
<li><i><a href="Measurement_of_a_Circle" title="Measurement of a Circle">Measurement of a Circle</a></i></li>
<li><i><a href="On_Conoids_and_Spheroids" title="On Conoids and Spheroids">On Conoids and Spheroids</a></i></li>
<li><a href="On_the_Sizes_and_Distances_(Aristarchus)" title="On the Sizes and Distances (Aristarchus)"><i>On the Sizes and Distances</i> <span style="font-size: 85%;">(Aristarchus)</span></a></li>
<li><a href="On_Sizes_and_Distances_(Hipparchus)" title="On Sizes and Distances (Hipparchus)"><i>On Sizes and Distances</i> <span style="font-size: 85%;">(Hipparchus)</span></a></li>
<li><a href="Autolycus_of_Pitane" title="Autolycus of Pitane"><i>On the Moving Sphere</i> <span style="font-size: 85%;">(Autolycus)</span></a></li>
<li><a href="Euclid's_Optics" title="Euclid's Optics"><i>Optics</i> <span style="font-size: 85%;">(Euclid)</span></a></li>
<li><i><a href="On_Spirals" title="On Spirals">On Spirals</a></i></li>
<li><i><a href="On_the_Sphere_and_Cylinder" title="On the Sphere and Cylinder">On the Sphere and Cylinder</a></i></li>
<li><i><a href="Ostomachion" title="Ostomachion">Ostomachion</a></i></li>
<li><a href="Euclid's_Phaenomena" title="Euclid's Phaenomena"><i>Phaenomena</i> <span style="font-size: 85%;">(Euclid)</span></a></li>
<li><i><a href="Planisphaerium" title="Planisphaerium">Planisphaerium</a></i></li>
<li><a href="Theodosius'_Spherics" title="Theodosius' Spherics"><i>Spherics</i> <span style="font-size: 85%;">(Theodosius)</span></a></li>
<li><a href="Menelaus_of_Alexandria" title="Menelaus of Alexandria"><i>Spherics</i> <span style="font-size: 85%;">(Menelaus)</span></a></li>
<li><i><a href="The_Quadrature_of_the_Parabola" class="mw-redirect" title="The Quadrature of the Parabola">The Quadrature of the Parabola</a></i></li>
<li><i><a href="The_Sand_Reckoner" title="The Sand Reckoner">The Sand Reckoner</a></i></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Concepts<br>and definitions</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chord_(geometry)" title="Chord (geometry)">Chord</a></li>
<li><a href="Circles_of_Apollonius" title="Circles of Apollonius">Circles of Apollonius</a>
<ul><li><a href="Apollonian_circles" title="Apollonian circles">Apollonian circles</a></li>
<li><a href="Apollonian_gasket" title="Apollonian gasket">Apollonian gasket</a></li>
<li><a href="Problem_of_Apollonius" title="Problem of Apollonius">Problem of Apollonius</a></li></ul></li>
<li><a href="Commensurability_(mathematics)" title="Commensurability (mathematics)">Commensurability</a></li>
<li><a href="Diophantine_equation" title="Diophantine equation">Diophantine equation</a></li>
<li><a href="Euclidean_geometry" title="Euclidean geometry">Euclidean geometry</a></li>
<li><a href="Golden_ratio" title="Golden ratio">Golden ratio</a></li>
<li><a href="Lune_of_Hippocrates" title="Lune of Hippocrates">Lune of Hippocrates</a></li>
<li><a href="Method_of_exhaustion" title="Method of exhaustion">Method of exhaustion</a></li>
<li><a href="Parallel_postulate" title="Parallel postulate">Parallel postulate</a></li>
<li><a href="Platonic_solid" title="Platonic solid">Platonic solid</a></li>
<li><a href="Regular_polygon" title="Regular polygon">Regular polygon</a></li>
<li><a href="Straightedge_and_compass_construction" title="Straightedge and compass construction">Straightedge and compass construction</a>
<ul><li><a href="Angle_trisection" title="Angle trisection">Angle trisection</a></li>
<li><a href="Doubling_the_cube" title="Doubling the cube">Doubling the cube</a></li>
<li><a href="Squaring_the_circle" title="Squaring the circle">Squaring the circle</a></li>
<li><a href="Quadratrix_of_Hippias" title="Quadratrix of Hippias">Quadratrix of Hippias</a></li>
<li><a href="Neusis_construction" title="Neusis construction">Neusis construction</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Results</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th id="In_Elements37" scope="row" class="navbox-group" style="width:1%">In <a href="Euclid's_elements" class="mw-redirect" title="Euclid's elements"><i>Elements</i></a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Angle_bisector_theorem" title="Angle bisector theorem">Angle bisector theorem</a></li>
<li><a href="Exterior_angle_theorem" title="Exterior angle theorem">Exterior angle theorem</a></li>

<li><a href="Euclid's_theorem" title="Euclid's theorem">Euclid's theorem</a></li>
<li><a href="Geometric_mean_theorem" title="Geometric mean theorem">Geometric mean theorem</a></li>
<li><a href="Hinge_theorem" title="Hinge theorem">Hinge theorem</a></li>
<li><a href="Inscribed_angle_theorem" class="mw-redirect" title="Inscribed angle theorem">Inscribed angle theorem</a></li>
<li><a href="Intercept_theorem" title="Intercept theorem">Intercept theorem</a></li>
<li><a href="Intersecting_chords_theorem" title="Intersecting chords theorem">Intersecting chords theorem</a></li>
<li><a href="Intersecting_secants_theorem" title="Intersecting secants theorem">Intersecting secants theorem</a></li>
<li><a href="Law_of_cosines" title="Law of cosines">Law of cosines</a></li>
<li><a href="Pons_asinorum" title="Pons asinorum">Pons asinorum</a></li>
<li><a href="Pythagorean_theorem" title="Pythagorean theorem">Pythagorean theorem</a></li>
<li><a href="Tangent-secant_theorem" class="mw-redirect" title="Tangent-secant theorem">Tangent-secant theorem</a></li>
<li><a href="Thales's_theorem" title="Thales's theorem">Thales's theorem</a></li>
<li><a href="Theorem_of_the_gnomon" title="Theorem of the gnomon">Theorem of the gnomon</a></li></ul>
</div></td></tr></tbody></table><div>
<ul><li><a href="Apollonius's_theorem" title="Apollonius's theorem">Apollonius's theorem</a></li>
<li><a href="Aristarchus's_inequality" title="Aristarchus's inequality">Aristarchus's inequality</a></li>
<li><a href="Heron's_formula" title="Heron's formula">Heron's formula</a></li>
<li><a href="Law_of_sines" title="Law of sines">Law of sines</a></li>
<li><a href="Menelaus's_theorem" title="Menelaus's theorem">Menelaus's theorem</a></li>
<li><a href="Pappus's_area_theorem" title="Pappus's area theorem">Pappus's area theorem</a></li>
<li><a href="Diophantus_II.VIII" title="Diophantus II.VIII">Problem II.8 of <i>Arithmetica</i></a></li>
<li><a href="Ptolemy's_inequality" title="Ptolemy's inequality">Ptolemy's inequality</a></li>
<li><a href="Ptolemy's_table_of_chords" title="Ptolemy's table of chords">Ptolemy's table of chords</a></li>
<li><a href="Ptolemy's_theorem" title="Ptolemy's theorem">Ptolemy's theorem</a></li>
<li><a href="Spiral_of_Theodorus" title="Spiral of Theodorus">Spiral of Theodorus</a></li></ul></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Centers/Schools</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<li><a href="Cyrene%2C_Libya" title="Cyrene, Libya">Cyrene</a></li>
<li><a href="Platonic_Academy" title="Platonic Academy">Platonic Academy</a></li>
<li><a href="Pythagoreanism" title="Pythagoreanism">Pythagoreanism</a></li>
<li><a href="School_of_Chios" title="School of Chios">School of Chios</a></li>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><td colspan="2" class="navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ancient_Greek_astronomy" title="Ancient Greek astronomy">Ancient Greek astronomy</a></li>
<li><a href="Attic_numerals" title="Attic numerals">Attic numerals</a></li>
<li><a href="Greek_numerals" title="Greek numerals">Greek numerals</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">History of</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><i><a href="A_History_of_Greek_Mathematics" title="A History of Greek Mathematics">A History of Greek Mathematics</a></i>
<ul><li>by <a href="Thomas_Heath_(classicist)" title="Thomas Heath (classicist)">Thomas Heath</a></li></ul></li>
<li><a href="Archimedes_Palimpsest" title="Archimedes Palimpsest">Archimedes Palimpsest</a></li>
<li><a href="History_of_algebra" title="History of algebra">algebra</a>
<ul><li><a href="Timeline_of_algebra" title="Timeline of algebra">timeline</a></li></ul></li>
<li><a href="History_of_arithmetic" class="mw-redirect" title="History of arithmetic">arithmetic</a>
<ul><li><a href="Timeline_of_numerals_and_arithmetic" title="Timeline of numerals and arithmetic">timeline</a></li></ul></li>
<li><a href="History_of_calculus" title="History of calculus">calculus</a>
<ul><li><a href="Timeline_of_calculus_and_mathematical_analysis" title="Timeline of calculus and mathematical analysis">timeline</a></li></ul></li>
<li><a href="History_of_geometry" title="History of geometry">geometry</a>
<ul><li><a href="Timeline_of_geometry" title="Timeline of geometry">timeline</a></li></ul></li>
<li><a href="History_of_logic" title="History of logic">logic</a>
<ul><li><a href="Timeline_of_mathematical_logic" title="Timeline of mathematical logic">timeline</a></li></ul></li>
<li><a href="History_of_mathematics" title="History of mathematics">mathematics</a>
<ul><li><a href="Timeline_of_mathematics" title="Timeline of mathematics">timeline</a></li></ul></li>
<li><a href="History_of_numbers" class="mw-redirect" title="History of numbers">numbers</a>
<ul><li><a href="Prehistoric_counting" class="mw-redirect" title="Prehistoric counting">prehistoric counting</a></li></ul></li>
<li><a href="History_of_ancient_numeral_systems" title="History of ancient numeral systems">numeral systems</a>
<ul><li><a href="List_of_numeral_systems" title="List of numeral systems">list</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other cultures</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Mathematics_in_the_medieval_Islamic_world" title="Mathematics in the medieval Islamic world">Arabian/Islamic</a></li>
<li><a href="Babylonian_mathematics" title="Babylonian mathematics">Babylonian</a></li>
<li><a href="Chinese_mathematics" title="Chinese mathematics">Chinese</a></li>
<li><a href="Ancient_Egyptian_mathematics" title="Ancient Egyptian mathematics">Egyptian</a></li>
<li><a href="Mathematics_of_the_Incas" title="Mathematics of the Incas">Incan</a></li>
<li><a href="Indian_mathematics" title="Indian mathematics">Indian</a></li>
<li><a href="Japanese_mathematics" title="Japanese mathematics">Japanese</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div><b><span class="nowrap"><span class="noviewer" typeof="mw:File"><span></span></span> </span><a href="Portal%3AAncient_Greece" title="Portal:Ancient Greece">Ancient Greece portal</a></b>&nbsp;• <b><span class="nowrap"><span class="skin-invert-image noviewer" typeof="mw:File"></span> </span><a href="Portal%3AMathematics" title="Portal:Mathematics">Mathematics portal</a></b></div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox authority-control" aria-label="Navbox390" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Authority control databases: National </th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4659898-4">Germany</a></span></li></ul></div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-25" href="https://en.wikipedia.org/wiki/?title=Euclidean_algorithm&amp;oldid=1302372519">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>